feat(item.itemType): added section itemType
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
7f19f0bebe
commit
734f9cb60d
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -18,10 +18,13 @@
|
|||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"life": {
|
||||
"workerFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"isPackaging": {
|
||||
"categoryFk": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"temperatureFk": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -23,4 +23,4 @@ import './waste/index/';
|
|||
import './waste/detail';
|
||||
import './fixed-price';
|
||||
import './fixed-price-search-panel';
|
||||
|
||||
import './item-type';
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="ItemTypes"
|
||||
data="$ctrl.role"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<form
|
||||
name="form"
|
||||
ng-submit="watcher.submit()"
|
||||
class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-vertical>
|
||||
<vn-textfield
|
||||
label="Name"
|
||||
ng-model="$ctrl.role.name"
|
||||
rule
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
label="Description"
|
||||
ng-model="$ctrl.role.description"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit
|
||||
disabled="!watcher.dataChanged()"
|
||||
label="Save">
|
||||
</vn-submit>
|
||||
<vn-button
|
||||
class="cancel"
|
||||
label="Undo changes"
|
||||
disabled="!watcher.dataChanged()"
|
||||
ng-click="watcher.loadOriginalData()">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -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: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
<vn-portal slot="menu">
|
||||
<vn-item-type-descriptor itemType="$ctrl.itemType"></vn-item-type-descriptor>
|
||||
<vn-left-menu source="itemType"></vn-left-menu>
|
||||
</vn-portal>
|
||||
<ui-view></ui-view>
|
|
@ -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
|
||||
});
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,38 @@
|
|||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="Roles"
|
||||
data="$ctrl.role"
|
||||
insert-mode="true"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<form
|
||||
name="form"
|
||||
vn-http-submit="$ctrl.onSubmit()"
|
||||
class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-vertical>
|
||||
<vn-textfield
|
||||
label="Name"
|
||||
ng-model="$ctrl.role.name"
|
||||
rule
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
label="Description"
|
||||
ng-model="$ctrl.role.description"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit
|
||||
disabled="!watcher.dataChanged()"
|
||||
label="Create">
|
||||
</vn-submit>
|
||||
<vn-button
|
||||
class="cancel"
|
||||
label="Cancel"
|
||||
ui-sref="account.role">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -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
|
||||
});
|
|
@ -0,0 +1,27 @@
|
|||
<vn-descriptor-content
|
||||
module="item"
|
||||
base-state="item.itemType"
|
||||
description="$ctrl.itemType.name">
|
||||
<slot-menu>
|
||||
<vn-item
|
||||
ng-click="deleteItemType.show()"
|
||||
name="deleteItemType"
|
||||
translate>
|
||||
Delete
|
||||
</vn-item>
|
||||
</slot-menu>
|
||||
<slot-body>
|
||||
<div class="attributes">
|
||||
<vn-label-value
|
||||
label="Name"
|
||||
value="{{$ctrl.itemType.name}}">
|
||||
</vn-label-value>
|
||||
</div>
|
||||
</slot-body>
|
||||
</vn-descriptor-content>
|
||||
<vn-confirm
|
||||
vn-id="delete-itemType"
|
||||
on-accept="$ctrl.onDelete()"
|
||||
question="Are you sure you want to continue?"
|
||||
message="ItemType will be removed">
|
||||
</vn-confirm>
|
|
@ -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: '<'
|
||||
}
|
||||
});
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,2 @@
|
|||
Role will be removed: El rol va a ser eliminado
|
||||
Role removed: Rol eliminado
|
|
@ -0,0 +1,8 @@
|
|||
import './main';
|
||||
import './index/';
|
||||
import './summary';
|
||||
import './card';
|
||||
import './descriptor';
|
||||
import './search-panel';
|
||||
import './create';
|
||||
import './basic-data';
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
<vn-crud-model
|
||||
vn-id="model"
|
||||
auto-load="true"
|
||||
url="ItemTypes"
|
||||
data="itemTypes"
|
||||
order="name">
|
||||
</vn-crud-model>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
class="vn-w-sm">
|
||||
<vn-card>
|
||||
<div class="vn-list separated">
|
||||
<a
|
||||
ng-repeat="itemType in itemTypes track by itemType.id"
|
||||
ui-sref="item.itemType.card.summary(::{id: itemType.id})"
|
||||
ui-sref-opts="{inherit: false}"
|
||||
translate-attr="{title: 'View itemType'}"
|
||||
class="vn-item search-result">
|
||||
<vn-item-section>
|
||||
<h6>{{::itemType.code}}</h6>
|
||||
<div>{{::itemType.name}}</div>
|
||||
</vn-item-section>
|
||||
<vn-item-section side>
|
||||
<vn-icon-button
|
||||
vn-click-stop="$ctrl.preview(itemType)"
|
||||
vn-tooltip="Preview"
|
||||
icon="preview">
|
||||
</vn-icon-button>
|
||||
</vn-item-section>
|
||||
</a>
|
||||
</div>
|
||||
</vn-card>
|
||||
</vn-data-viewer>
|
||||
<vn-popup vn-id="summary">
|
||||
<vn-item-type-summary itemType="$ctrl.selectedItemType"></vn-item-type-summary>
|
||||
</vn-popup>
|
||||
<a ui-sref="account.role.create"
|
||||
ui-sref-opts="{inherit: false}"
|
||||
vn-tooltip="New role"
|
||||
vn-bind="+"
|
||||
vn-acl="it"
|
||||
vn-acl-action="remove"
|
||||
fixed-bottom-right>
|
||||
<vn-float-button icon="add"></vn-float-button>
|
||||
</a>
|
|
@ -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
|
||||
});
|
|
@ -0,0 +1 @@
|
|||
Item Type: Familia
|
|
@ -0,0 +1,18 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="ItemTypes"
|
||||
filter="::$ctrl.filter"
|
||||
limit="20">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
info="Search itemType by id, name or code"
|
||||
panel="vn-item-type-search-panel"
|
||||
model="model"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)"
|
||||
base-state="item.itemType">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<ui-view>
|
||||
<vn-item-type-index></vn-item-type-index>
|
||||
</ui-view>
|
|
@ -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')
|
||||
});
|
|
@ -0,0 +1,21 @@
|
|||
<div class="search-panel">
|
||||
<form ng-submit="$ctrl.onSearch()">
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Code"
|
||||
ng-model="filter.code">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Name"
|
||||
ng-model="filter.name">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-mt-lg">
|
||||
<vn-submit label="Search"></vn-submit>
|
||||
</vn-horizontal>
|
||||
</form>
|
||||
</div>
|
|
@ -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
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
<vn-card class="summary">
|
||||
<h5>{{summary.name}}</h5>
|
||||
<vn-horizontal class="vn-pa-md">
|
||||
<vn-one>
|
||||
<h4 translate>Basic data</h4>
|
||||
<vn-label-value
|
||||
label="Id"
|
||||
value="{{summary.id}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Name"
|
||||
value="{{summary.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Description"
|
||||
value="{{summary.description}}">
|
||||
</vn-label-value>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
|
@ -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: '<'
|
||||
}
|
||||
});
|
|
@ -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"]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue