html changes

This commit is contained in:
Joan Sanchez 2020-09-08 10:11:22 +02:00
parent 7b9205ee1e
commit 8daa3ae89c
4 changed files with 108 additions and 7 deletions

View File

@ -1,6 +1,7 @@
<mg-ajax path="Tags" options="mgIndex as tags"></mg-ajax>
<div class="vn-pa-lg" style="min-width: 10em"> <div class="vn-pa-lg" style="min-width: 10em">
<form name="form" ng-submit="$ctrl.onSearch()"> <form name="form" ng-submit="$ctrl.onSearch()">
<vn-horizontal> <!-- <vn-horizontal>
<vn-autocomplete <vn-autocomplete
vn-one vn-one
label="Tag" label="Tag"
@ -20,7 +21,67 @@
ng-model="filter.value" ng-model="filter.value"
required="true"> required="true">
</vn-textfield> </vn-textfield>
</vn-horizontal> -->
<vn-horizontal class="vn-pt-sm">
<vn-one class="text-subtitle1" translate>
Tags
</vn-one>
<vn-icon-button
vn-none
vn-bind="+"
vn-tooltip="Add tag"
icon="add_circle"
ng-click="$ctrl.addTag()">
</vn-icon-button>
</vn-horizontal> </vn-horizontal>
<vn-horizontal ng-repeat="itemTag in filter.tags">
<vn-autocomplete
vn-id="tag"
vn-one
ng-model="itemTag.tagFk"
data="tags.model"
show-field="name"
label="Tag"
on-change="itemTag.value = null">
</vn-autocomplete>
<vn-textfield
vn-one
ng-show="tag.selection.isFree !== false"
vn-id="text"
label="Value"
ng-model="itemTag.value">
</vn-textfield>
<vn-autocomplete
vn-one
ng-show="tag.selection.isFree === false"
url="{{$ctrl.getSourceTable(tag.selection)}}"
label="Value"
ng-model="itemTag.value"
show-field="name"
value-field="name">
</vn-autocomplete>
<vn-icon-button
vn-none
vn-tooltip="Remove tag"
icon="delete"
ng-click="filter.tags.splice($index, 1)"
tabindex="-1">
</vn-icon-button>
</vn-horizontal>
<vn-horizontal class="vn-mt-lg"> <vn-horizontal class="vn-mt-lg">
<vn-submit label="Search"></vn-submit> <vn-submit label="Search"></vn-submit>
</vn-horizontal> </vn-horizontal>

View File

@ -1,10 +1,49 @@
import ngModule from '../module'; import ngModule from '../module';
import SearchPanel from 'core/components/searchbar/search-panel'; import SearchPanel from 'core/components/searchbar/search-panel';
class Controller extends SearchPanel {
constructor($element, $) {
super($element, $);
this.filter = {};
}
get filter() {
return this.$.filter;
}
set filter(value) {
if (!value)
value = {};
if (!value.tags)
value.tags = [{}];
this.$.filter = value;
}
getSourceTable(selection) {
if (!selection || selection.isFree === true)
return null;
if (selection.sourceTable) {
return ''
+ selection.sourceTable.charAt(0).toUpperCase()
+ selection.sourceTable.substring(1) + 's';
} else if (selection.sourceTable == null)
return `ItemTags/filterItemTags/${selection.id}`;
}
addTag() {
this.filter.tags.push({});
this.popover.relocate();
}
}
ngModule.vnComponent('vnOrderCatalogSearchPanel', { ngModule.vnComponent('vnOrderCatalogSearchPanel', {
template: require('./index.html'), template: require('./index.html'),
controller: SearchPanel, controller: Controller,
bindings: { bindings: {
onSubmit: '&?' onSubmit: '&?',
popover: '<?'
} }
}); });

View File

@ -106,8 +106,8 @@
vn-id="popover" vn-id="popover"
on-close="$ctrl.onPopoverClose()"> on-close="$ctrl.onPopoverClose()">
<vn-order-catalog-search-panel <vn-order-catalog-search-panel
filter="panelFilter" on-submit="$ctrl.onPanelSubmit($filter)"
on-submit="$ctrl.onPanelSubmit($filter)"> popover="popover">
</vn-order-catalog-search-panel> </vn-order-catalog-search-panel>
</vn-popover> </vn-popover>
<div class="chips"> <div class="chips">

View File

@ -243,10 +243,11 @@ class Controller extends Section {
} }
onPanelSubmit(filter) { onPanelSubmit(filter) {
this.$.popover.hide(); console.log(filter);
/* this.$.popover.hide();
this.tags.push(filter); this.tags.push(filter);
this.updateStateParams(); this.updateStateParams();
this.applyFilters(); this.applyFilters(); */
} }
/** /**