vn table now receives show buttons options
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Carlos Jimenez Ruiz 2021-10-29 16:55:19 +02:00
parent 11f24372e5
commit 04a31f4cff
4 changed files with 29 additions and 36 deletions

View File

@ -2,7 +2,7 @@
<vn-horizontal>
<div class="actions-left">
<vn-button icon="view_column"
ng-if="$ctrl.viewConfigId"
ng-if="$ctrl.options.activeButtons.shownColumns"
ng-click="smartTableColumns.show($event)"
vn-tooltip="Shown columns">
</vn-button>
@ -10,10 +10,12 @@
</div>
<div class="actions-right">
<vn-button icon="search"
ng-if="$ctrl.options.activeButtons.search"
ng-click="$ctrl.displaySearch()"
vn-tooltip="Search">
</vn-button>
<div class="button-group">
<div class="button-group"
ng-if="$ctrl.options.activeButtons.crud">
<vn-button icon="add"
ng-click="$ctrl.createRow()"
vn-tooltip="Add new row">
@ -32,16 +34,10 @@
vn-tooltip="Save data">
</vn-button>
</div>
<div class="button-group">
<vn-button icon="refresh"
ng-click="$ctrl.model.refresh()"
vn-tooltip="Refresh">
</vn-button>
<vn-button icon="more_vert"
ng-click="moreOptions.show($event)"
vn-tooltip="More">
</vn-button>
</div>
<vn-button icon="refresh"
ng-click="$ctrl.model.refresh()"
vn-tooltip="Refresh">
</vn-button>
</div>
</vn-horizontal>
@ -62,6 +58,7 @@
</vn-confirm>
<vn-crud-model
ng-if="$ctrl.viewConfigId"
vn-id="userViewModel"
url="UserConfigViews"
link="{tableCode: $ctrl.viewConfigId, userFk: $ctrl.currentUserId}"

View File

@ -15,6 +15,20 @@ export default class SmartTable extends Component {
this.autoSave = false;
}
get options() {
return this._options;
}
set options(options) {
this._options = options;
if (!options) return;
const activeButtons = options.activeButtons;
const missingId = activeButtons && activeButtons.shownColumns && !this.viewConfigId;
if (missingId)
throw new Error('vnSmartTable: View identifier not defined');
}
get model() {
return this._model;
}

View File

@ -1,14 +1,7 @@
<vn-auto-search
model="model">
</vn-auto-search>
<!-- <vn-crud-model auto-load="true"
vn-id="model"
url="Tickets"
limit="20"
order="id DESC">
</vn-crud-model> -->
<vn-card>
<!-- To access table component should be a nested component -->
<smart-table
model="model"
view-config-id="ticketIndex"
@ -16,22 +9,6 @@
auto-save="true"
expr-builder="$ctrl.exprBuilder(param, value)"
default-new-data="$ctrl.defaultNewData()">
<slot-actions>
<vn-button icon="info"
ng-click="$ctrl.test()"
vn-tooltip="Info">
</vn-button>
<div class="button-group">
<vn-button icon="info"
ng-click="$ctrl.test()"
vn-tooltip="Info">
</vn-button>
<vn-button icon="info"
ng-click="$ctrl.test()"
vn-tooltip="Info">
</vn-button>
</div>
</slot-actions>
<slot-table>
<table class="vn-table">
<thead>

View File

@ -8,6 +8,11 @@ export default class Controller extends Section {
super($element, $);
this.vnReport = vnReport;
this.smartTableOptions = {
activeButtons: {
search: true,
crud: true,
shownColumns: true,
},
columns: [
{
field: 'salesPersonFk',