diff --git a/modules/account/front/role/index/index.js b/modules/account/front/role/index/index.js index 40773b23b..49b9be53b 100644 --- a/modules/account/front/role/index/index.js +++ b/modules/account/front/role/index/index.js @@ -4,6 +4,7 @@ import Section from 'salix/components/section'; export default class Controller extends Section { preview(role) { this.selectedRole = role; + console.log(this.selectedRole); this.$.summary.show(); } } diff --git a/modules/account/front/role/summary/index.js b/modules/account/front/role/summary/index.js index 0a08fe8b2..eb528a894 100644 --- a/modules/account/front/role/summary/index.js +++ b/modules/account/front/role/summary/index.js @@ -6,6 +6,7 @@ class Controller extends Component { this._role = value; this.$.summary = null; if (!value) return; + console.log(value); this.$http.get(`Roles/${value.id}`) .then(res => this.$.summary = res.data); diff --git a/modules/item/back/models/item-type.json b/modules/item/back/models/item-type.json index cb9d5ace8..b7a8ced2f 100644 --- a/modules/item/back/models/item-type.json +++ b/modules/item/back/models/item-type.json @@ -18,10 +18,13 @@ "name": { "type": "string" }, - "life": { + "workerFk": { "type": "number" }, - "isPackaging": { + "categoryFk": { + "type": "boolean" + }, + "temperatureFk": { "type": "boolean" } }, diff --git a/modules/item/front/index.js b/modules/item/front/index.js index c328b1c8d..6a8d1b3b7 100644 --- a/modules/item/front/index.js +++ b/modules/item/front/index.js @@ -23,4 +23,4 @@ import './waste/index/'; import './waste/detail'; import './fixed-price'; import './fixed-price-search-panel'; - +import './item-type'; diff --git a/modules/item/front/item-type/basic-data/index.html b/modules/item/front/item-type/basic-data/index.html new file mode 100644 index 000000000..f2888fcdf --- /dev/null +++ b/modules/item/front/item-type/basic-data/index.html @@ -0,0 +1,38 @@ + + +
+ + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/modules/item/front/item-type/basic-data/index.js b/modules/item/front/item-type/basic-data/index.js new file mode 100644 index 000000000..fdb0305d6 --- /dev/null +++ b/modules/item/front/item-type/basic-data/index.js @@ -0,0 +1,12 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section {} + +ngModule.component('vnItemTypeBasicData', { + template: require('./index.html'), + controller: Controller, + bindings: { + role: '<' + } +}); diff --git a/modules/item/front/item-type/card/index.html b/modules/item/front/item-type/card/index.html new file mode 100644 index 000000000..5ed275c6a --- /dev/null +++ b/modules/item/front/item-type/card/index.html @@ -0,0 +1,5 @@ + + + + + diff --git a/modules/item/front/item-type/card/index.js b/modules/item/front/item-type/card/index.js new file mode 100644 index 000000000..090279c5b --- /dev/null +++ b/modules/item/front/item-type/card/index.js @@ -0,0 +1,17 @@ +import ngModule from '../../module'; +import ModuleCard from 'salix/components/module-card'; + +class Controller extends ModuleCard { + reload() { + this.$http.get(`ItemTypes/${this.$params.id}`) + .then(res => { + this.itemType = res.data; + console.log(this.itemType); + }); + } +} + +ngModule.vnComponent('vnItemTypeCard', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/item/front/item-type/card/index.spec.js b/modules/item/front/item-type/card/index.spec.js new file mode 100644 index 000000000..f39840e5f --- /dev/null +++ b/modules/item/front/item-type/card/index.spec.js @@ -0,0 +1,25 @@ +import './index'; + +describe('component vnRoleCard', () => { + let controller; + let $httpBackend; + + beforeEach(ngModule('account')); + + beforeEach(inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; + controller = $componentController('vnRoleCard', {$element: null}); + })); + + describe('reload()', () => { + it('should reload the controller data', () => { + controller.$params.id = 1; + + $httpBackend.expectGET('Roles/1').respond('foo'); + controller.reload(); + $httpBackend.flush(); + + expect(controller.role).toBe('foo'); + }); + }); +}); diff --git a/modules/item/front/item-type/create/index.html b/modules/item/front/item-type/create/index.html new file mode 100644 index 000000000..02900d580 --- /dev/null +++ b/modules/item/front/item-type/create/index.html @@ -0,0 +1,38 @@ + + +
+ + + + + + + + + + + + + + +
diff --git a/modules/item/front/item-type/create/index.js b/modules/item/front/item-type/create/index.js new file mode 100644 index 000000000..1474ad5e5 --- /dev/null +++ b/modules/item/front/item-type/create/index.js @@ -0,0 +1,15 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + onSubmit() { + return this.$.watcher.submit().then(res => + this.$state.go('account.role.card.basicData', {id: res.data.id}) + ); + } +} + +ngModule.component('vnItemTypeCreate', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/item/front/item-type/descriptor/index.html b/modules/item/front/item-type/descriptor/index.html new file mode 100644 index 000000000..e4b8a6bbf --- /dev/null +++ b/modules/item/front/item-type/descriptor/index.html @@ -0,0 +1,27 @@ + + + + Delete + + + +
+ + +
+
+
+ + \ No newline at end of file diff --git a/modules/item/front/item-type/descriptor/index.js b/modules/item/front/item-type/descriptor/index.js new file mode 100644 index 000000000..83c9a1da2 --- /dev/null +++ b/modules/item/front/item-type/descriptor/index.js @@ -0,0 +1,30 @@ +import ngModule from '../../module'; +import Descriptor from 'salix/components/descriptor'; + +class Controller extends Descriptor { + $onInit() { + console.log(this.itemType, this.entity); + } + + get itemType() { + return this.entity; + } + + set itemType(value) { + this.entity = value; + } + + onDelete() { + return this.$http.delete(`ItemTypes/${this.id}`) + .then(() => this.$state.go('item.itemType')) + .then(() => this.vnApp.showSuccess(this.$t('ItemType removed'))); + } +} + +ngModule.component('vnItemTypeDescriptor', { + template: require('./index.html'), + controller: Controller, + bindings: { + itemType: '<' + } +}); diff --git a/modules/item/front/item-type/descriptor/index.spec.js b/modules/item/front/item-type/descriptor/index.spec.js new file mode 100644 index 000000000..e2761c639 --- /dev/null +++ b/modules/item/front/item-type/descriptor/index.spec.js @@ -0,0 +1,29 @@ +import './index'; + +describe('component vnRoleDescriptor', () => { + let controller; + let $httpBackend; + + let role = {id: 1, name: 'foo'}; + + beforeEach(ngModule('account')); + + beforeEach(inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; + controller = $componentController('vnRoleDescriptor', {$element: null}, {role}); + })); + + describe('onDelete()', () => { + it('should delete entity and go to index', () => { + controller.$state.go = jest.fn(); + jest.spyOn(controller.vnApp, 'showSuccess'); + + $httpBackend.expectDELETE('Roles/1').respond(); + controller.onDelete(); + $httpBackend.flush(); + + expect(controller.$state.go).toHaveBeenCalledWith('account.role'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); + }); + }); +}); diff --git a/modules/item/front/item-type/descriptor/locale/es.yml b/modules/item/front/item-type/descriptor/locale/es.yml new file mode 100644 index 000000000..1ca512e4f --- /dev/null +++ b/modules/item/front/item-type/descriptor/locale/es.yml @@ -0,0 +1,2 @@ +Role will be removed: El rol va a ser eliminado +Role removed: Rol eliminado \ No newline at end of file diff --git a/modules/item/front/item-type/index.js b/modules/item/front/item-type/index.js new file mode 100644 index 000000000..c8282e196 --- /dev/null +++ b/modules/item/front/item-type/index.js @@ -0,0 +1,8 @@ +import './main'; +import './index/'; +import './summary'; +import './card'; +import './descriptor'; +import './search-panel'; +import './create'; +import './basic-data'; diff --git a/modules/item/front/item-type/index/index.html b/modules/item/front/item-type/index/index.html new file mode 100644 index 000000000..459b5d71c --- /dev/null +++ b/modules/item/front/item-type/index/index.html @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/item/front/item-type/index/index.js b/modules/item/front/item-type/index/index.js new file mode 100644 index 000000000..5530e5cf3 --- /dev/null +++ b/modules/item/front/item-type/index/index.js @@ -0,0 +1,15 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + preview(itemType) { + this.selectedItemType = itemType; + console.log(this.selectedItemType); + this.$.summary.show(); + } +} + +ngModule.component('vnItemTypeIndex', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/item/front/item-type/index/locale/es.yml b/modules/item/front/item-type/index/locale/es.yml new file mode 100644 index 000000000..3a36f7c96 --- /dev/null +++ b/modules/item/front/item-type/index/locale/es.yml @@ -0,0 +1 @@ +Item Type: Familia \ No newline at end of file diff --git a/modules/item/front/item-type/main/index.html b/modules/item/front/item-type/main/index.html new file mode 100644 index 000000000..faba696c0 --- /dev/null +++ b/modules/item/front/item-type/main/index.html @@ -0,0 +1,18 @@ + + + + + + + + + \ No newline at end of file diff --git a/modules/item/front/item-type/main/index.js b/modules/item/front/item-type/main/index.js new file mode 100644 index 000000000..0dea00abb --- /dev/null +++ b/modules/item/front/item-type/main/index.js @@ -0,0 +1,24 @@ +import ngModule from '../../module'; +import ModuleMain from 'salix/components/module-main'; + +export default class ItemType extends ModuleMain { + exprBuilder(param, value) { + switch (param) { + case 'search': + return /^\d+$/.test(value) + ? {id: value} + : {or: [ + {name: {like: `%${value}%`}}, + {code: {like: `%${value}%`}} + ]}; + case 'name': + case 'code': + return {[param]: {like: `%${value}%`}}; + } + } +} + +ngModule.vnComponent('vnItemType', { + controller: ItemType, + template: require('./index.html') +}); diff --git a/modules/item/front/item-type/search-panel/index.html b/modules/item/front/item-type/search-panel/index.html new file mode 100644 index 000000000..ce2919910 --- /dev/null +++ b/modules/item/front/item-type/search-panel/index.html @@ -0,0 +1,21 @@ +
+
+ + + + + + + + + + + +
+
\ No newline at end of file diff --git a/modules/item/front/item-type/search-panel/index.js b/modules/item/front/item-type/search-panel/index.js new file mode 100644 index 000000000..3a6ed4f86 --- /dev/null +++ b/modules/item/front/item-type/search-panel/index.js @@ -0,0 +1,7 @@ +import ngModule from '../../module'; +import SearchPanel from 'core/components/searchbar/search-panel'; + +ngModule.component('vnItemTypePanel', { + template: require('./index.html'), + controller: SearchPanel +}); diff --git a/modules/item/front/item-type/summary/index.html b/modules/item/front/item-type/summary/index.html new file mode 100644 index 000000000..f7971190c --- /dev/null +++ b/modules/item/front/item-type/summary/index.html @@ -0,0 +1,20 @@ + +
{{summary.name}}
+ + +

Basic data

+ + + + + + +
+
+
\ No newline at end of file diff --git a/modules/item/front/item-type/summary/index.js b/modules/item/front/item-type/summary/index.js new file mode 100644 index 000000000..1048fa88d --- /dev/null +++ b/modules/item/front/item-type/summary/index.js @@ -0,0 +1,26 @@ +import ngModule from '../../module'; +import Component from 'core/lib/component'; + +class Controller extends Component { + set itemType(value) { + this._itemType = value; + this.$.summary = null; + if (!value) return; + console.log(value); + + this.$http.get(`ItemTypes/${value.id}`) + .then(res => console.log(res.data)); + } + + get itemType() { + return this._itemType; + } +} + +ngModule.component('vnItemTypeSummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + itemType: '<' + } +}); diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json index 9e21e1697..400399c38 100644 --- a/modules/item/front/routes.json +++ b/modules/item/front/routes.json @@ -9,7 +9,8 @@ {"state": "item.index", "icon": "icon-item"}, {"state": "item.request", "icon": "icon-buyrequest"}, {"state": "item.waste.index", "icon": "icon-claims"}, - {"state": "item.fixedPrice", "icon": "icon-fixedPrice"} + {"state": "item.fixedPrice", "icon": "icon-fixedPrice"}, + {"state": "item.itemType", "icon": "contact_support"} ], "card": [ {"state": "item.card.basicData", "icon": "settings"}, @@ -169,6 +170,47 @@ "component": "vn-fixed-price", "description": "Fixed prices", "acl": ["buyer"] + }, + { + "url" : "/item-type?q", + "state": "item.itemType", + "component": "vn-item-type", + "description": "Item Type", + "acl": ["buyer"] + }, + { + "url": "/create", + "state": "item.itemType.create", + "component": "vn-item-type-create", + "description": "New itemType", + "acl": ["buyer"] + }, + { + "url": "/:id", + "state": "item.itemType.card", + "component": "vn-item-type-card", + "abstract": true, + "description": "Detail" + }, + { + "url": "/summary", + "state": "item.itemType.card.summary", + "component": "vn-item-type-summary", + "description": "Summary", + "params": { + "itemType": "$ctrl.itemType" + }, + "acl": ["buyer"] + }, + { + "url": "/basic-data", + "state": "item.itemType.card.basicData", + "component": "vn-item-type-basic-data", + "description": "Basic data", + "params": { + "itemType": "$ctrl.itemType" + }, + "acl": ["buyer"] } ] } \ No newline at end of file