semantics and tests
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
df4ebbd775
commit
3b7455ab24
|
@ -20,7 +20,7 @@
|
||||||
<vn-icon
|
<vn-icon
|
||||||
vn-tooltip="Move left"
|
vn-tooltip="Move left"
|
||||||
class="small-icon"
|
class="small-icon"
|
||||||
ng-click="$ctrl.moveModule(mod, $event, 'increase')"
|
ng-click="$ctrl.moveModule(mod, $event, 'left')"
|
||||||
icon="arrow_left">
|
icon="arrow_left">
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
<vn-icon
|
<vn-icon
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
<vn-icon
|
<vn-icon
|
||||||
vn-tooltip="Move right"
|
vn-tooltip="Move right"
|
||||||
class="small-icon"
|
class="small-icon"
|
||||||
ng-click="$ctrl.moveModule(mod, $event, 'decrease')"
|
ng-click="$ctrl.moveModule(mod, $event, 'right')"
|
||||||
icon="arrow_right">
|
icon="arrow_right">
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -77,12 +77,12 @@ export default class Controller extends Component {
|
||||||
return this.$sce.trustAsHtml(getName(mod));
|
return this.$sce.trustAsHtml(getName(mod));
|
||||||
}
|
}
|
||||||
|
|
||||||
moveModule(module, event, action) {
|
moveModule(module, event, direction) {
|
||||||
if (event.defaultPrevented) return;
|
if (event.defaultPrevented) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
const params = {moduleName: module.name, action: action};
|
const params = {moduleName: module.name, direction: direction};
|
||||||
const query = `starredModules/setPosition`;
|
const query = `starredModules/setPosition`;
|
||||||
this.$http.post(query, params).then(res => {
|
this.$http.post(query, params).then(res => {
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ describe('Salix Component vnHome', () => {
|
||||||
expect(controller._modules[0].starred).toBe(true);
|
expect(controller._modules[0].starred).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should set the received module as regular if it was starred`, () => {
|
it('should set the received module as regular if it was starred', () => {
|
||||||
const event = new Event('target');
|
const event = new Event('target');
|
||||||
controller._modules = [{module: 'client', name: 'Clients', starred: true}];
|
controller._modules = [{module: 'client', name: 'Clients', starred: true}];
|
||||||
|
|
||||||
|
@ -72,4 +72,34 @@ describe('Salix Component vnHome', () => {
|
||||||
expect(controller._modules[0].starred).toBe(false);
|
expect(controller._modules[0].starred).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('moveModule()', () => {
|
||||||
|
it('should perform a query to setPosition and the apply the position to the moved and pushed modules', () => {
|
||||||
|
const starredModules = [
|
||||||
|
{id: 1, moduleFk: 'Clients', workerFk: 9},
|
||||||
|
{id: 2, moduleFk: 'Orders', workerFk: 9}
|
||||||
|
];
|
||||||
|
|
||||||
|
const movedModules = {
|
||||||
|
movingModule: {position: 2, moduleFk: 'Clients'},
|
||||||
|
pushedModule: {position: 1, moduleFk: 'Orders'}
|
||||||
|
};
|
||||||
|
const event = new Event('target');
|
||||||
|
controller._modules = [
|
||||||
|
{module: 'client', name: 'Clients', position: 1},
|
||||||
|
{module: 'orders', name: 'Orders', position: 2}
|
||||||
|
];
|
||||||
|
|
||||||
|
$httpBackend.whenRoute('GET', 'starredModules/getStarredModules').respond(starredModules);
|
||||||
|
$httpBackend.expectPOST('starredModules/setPosition').respond(movedModules);
|
||||||
|
|
||||||
|
expect(controller._modules[0].position).toEqual(1);
|
||||||
|
expect(controller._modules[1].position).toEqual(2);
|
||||||
|
controller.moveModule(controller._modules[0], event, 'right');
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller._modules[0].position).toEqual(2);
|
||||||
|
expect(controller._modules[1].position).toEqual(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue