refactor: refs #8081 recovered supplier decriptor and summary
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jon Elias 2025-03-03 11:15:55 +01:00
parent 9544894b17
commit 2afe4bb5b4
10 changed files with 522 additions and 1 deletions

View File

@ -95,7 +95,14 @@
</vn-td> </vn-td>
<vn-td number>{{::entry.weight | dashIfEmpty}}</vn-td> <vn-td number>{{::entry.weight | dashIfEmpty}}</vn-td>
<vn-td number>{{::entry.packagingFk | dashIfEmpty}}</vn-td> <vn-td number>{{::entry.packagingFk | dashIfEmpty}}</vn-td>
<vn-td class="expendable" title="{{::entry.supplier | dashIfEmpty}}">{{::entry.supplier | dashIfEmpty}}</vn-td> <!-- <vn-td class="expendable" title="{{::entry.supplier | dashIfEmpty}}">{{::entry.supplier | dashIfEmpty}}</vn-td> -->
<vn-td expand>
<span
vn-click-stop="supplierDescriptor.show($event, entry.supplierFk)"
class="link">
{{::entry.supplier | dashIfEmpty}}
</span>
</vn-td>
</vn-tr> </vn-tr>
</vn-tbody> </vn-tbody>
</vn-table> </vn-table>
@ -107,6 +114,10 @@
vn-id="entryDescriptor"> vn-id="entryDescriptor">
</vn-entry-descriptor-popover> </vn-entry-descriptor-popover>
<vn-supplier-descriptor-popover
vn-id="supplierDescriptor">
</vn-supplier-descriptor-popover>
<vn-contextmenu vn-id="contextmenu" targets="['vn-data-viewer']" model="model" <vn-contextmenu vn-id="contextmenu" targets="['vn-data-viewer']" model="model"
expr-builder="$ctrl.exprBuilder(param, value)"> expr-builder="$ctrl.exprBuilder(param, value)">
<slot-menu> <slot-menu>

View File

@ -0,0 +1,3 @@
<slot-descriptor>
<vn-supplier-descriptor></vn-supplier-descriptor>
</slot-descriptor>

View File

@ -0,0 +1,9 @@
import ngModule from '../module';
import DescriptorPopover from 'salix/components/descriptor-popover';
class Controller extends DescriptorPopover {}
ngModule.vnComponent('vnSupplierDescriptorPopover', {
slotTemplate: require('./index.html'),
controller: Controller
});

View File

@ -0,0 +1,66 @@
<vn-descriptor-content
module="supplier"
description="$ctrl.supplier.name"
summary="$ctrl.$.summary">
<slot-body>
<div class="attributes">
<vn-label-value label="Tax number"
value="{{$ctrl.supplier.nif}}">
</vn-label-value>
<vn-label-value label="Alias"
value="{{$ctrl.supplier.nickname}}">
</vn-label-value>
<vn-label-value label="Pay method"
value="{{$ctrl.supplier.payMethod.name}}">
</vn-label-value>
<vn-label-value label="Payment deadline"
value="{{$ctrl.supplier.payDem.payDem}}">
</vn-label-value>
<vn-label-value label="Pay day"
value="{{$ctrl.supplier.payDay}}">
</vn-label-value>
<vn-label-value label="Account"
value="{{$ctrl.supplier.account}}">
</vn-label-value>
</div>
<div class="icons">
<vn-icon
vn-tooltip="Inactive supplier"
icon="icon-disabled"
ng-if="$ctrl.supplier.isActive == false">
</vn-icon>
<vn-icon
vn-tooltip="Unverified supplier"
icon="icon-supplierfalse"
ng-if="$ctrl.supplier.isReal == false">
</vn-icon>
</div>
<div class="quicklinks">
<div ng-transclude="btnOne">
<vn-quick-link
tooltip="All entries with current supplier"
state="['entry.index', {q: $ctrl.entryFilter}]"
icon="icon-entry">
</vn-quick-link>
</div>
<div ng-transclude="btnTwo">
<vn-quick-link
ng-if="$ctrl.supplier.client.fi"
tooltip="Go to client"
state="['client.card.summary', {id: $ctrl.supplier.client.id}]"
icon="person">
</vn-quick-link>
</div>
<div ng-transclude="btnThree">
<vn-quick-link
tooltip="Create invoiceIn"
state="['invoiceIn.create', {supplierFk: $ctrl.id}]"
icon="icon-invoice-in-create">
</vn-quick-link>
</div>
</div>
</slot-body>
</vn-descriptor-content>
<vn-popup vn-id="summary">
<vn-supplier-summary supplier="$ctrl.supplier"></vn-supplier-summary>
</vn-popup>

View File

@ -0,0 +1,80 @@
import ngModule from '../module';
import Descriptor from 'salix/components/descriptor';
class Controller extends Descriptor {
get supplier() {
return this.entity;
}
set supplier(value) {
this.entity = value;
}
get entryFilter() {
if (!this.supplier) return null;
const date = Date.vnNew();
date.setHours(0, 0, 0, 0);
const from = new Date(date.getTime());
from.setDate(from.getDate() - 10);
const to = new Date(date.getTime());
to.setDate(to.getDate() + 10);
return JSON.stringify({
supplierFk: this.id,
from,
to
});
}
loadData() {
const filter = {
fields: [
'id',
'name',
'nickname',
'nif',
'payMethodFk',
'payDemFk',
'payDay',
'isActive',
'isReal',
'isTrucker',
'account'
],
include: [
{
relation: 'payMethod',
scope: {
fields: ['id', 'name']
}
},
{
relation: 'payDem',
scope: {
fields: ['id', 'payDem']
}
},
{
relation: 'client',
scope: {
fields: ['id', 'fi']
}
}
]
};
return this.getData(`Suppliers/${this.id}`, {filter})
.then(res => this.supplier = res.data);
}
}
ngModule.vnComponent('vnSupplierDescriptor', {
template: require('./index.html'),
controller: Controller,
bindings: {
supplier: '<'
}
});

View File

@ -1,3 +1,6 @@
export * from './module'; export * from './module';
import './main'; import './main';
import './descriptor';
import './descriptor-popover';
import './summary';

View File

@ -36,6 +36,146 @@
"state": "supplier.index", "state": "supplier.index",
"component": "vn-supplier-index", "component": "vn-supplier-index",
"description": "Suppliers" "description": "Suppliers"
},
{
"url": "/:id",
"state": "supplier.card",
"abstract": true,
"component": "vn-supplier-card"
},
{
"url": "/summary",
"state": "supplier.card.summary",
"component": "vn-supplier-summary",
"description": "Summary",
"params": {
"supplier": "$ctrl.supplier"
}
},
{
"url": "/create",
"state": "supplier.create",
"component": "vn-supplier-create",
"acl": ["administrative"],
"description": "New supplier"
},
{
"url": "/basic-data",
"state": "supplier.card.basicData",
"component": "vn-supplier-basic-data",
"description": "Basic data",
"acl": ["administrative"],
"params": {
"supplier": "$ctrl.supplier"
}
},
{
"url": "/fiscal-data",
"state": "supplier.card.fiscalData",
"component": "vn-supplier-fiscal-data",
"description": "Fiscal data",
"params": {
"supplier": "$ctrl.supplier"
},
"acl": ["administrative"]
},
{
"url" : "/log",
"state": "supplier.card.log",
"component": "vn-supplier-log",
"description": "Log"
},
{
"url": "/contact",
"state": "supplier.card.contact",
"component": "vn-supplier-contact",
"description": "Contacts",
"params": {
"supplier": "$ctrl.supplier"
}
},
{
"url": "/agency-term",
"state": "supplier.card.agencyTerm",
"component": "ui-view",
"abstract": true
},
{
"url": "/index",
"state": "supplier.card.agencyTerm.index",
"component": "vn-supplier-agency-term-index",
"description": "Agency Agreement",
"params": {
"supplier": "$ctrl.supplier"
}
},
{
"url": "/create",
"state": "supplier.card.agencyTerm.create",
"component": "vn-supplier-agency-term-create",
"description": "New autonomous",
"params": {
"supplier": "$ctrl.supplier"
}
},
{
"url": "/consumption?q",
"state": "supplier.card.consumption",
"component": "vn-supplier-consumption",
"description": "Consumption",
"params": {
"supplier": "$ctrl.supplier"
}
},
{
"url": "/billing-data",
"state": "supplier.card.billingData",
"component": "vn-supplier-billing-data",
"description": "Billing data",
"params": {
"supplier": "$ctrl.supplier"
},
"acl": ["administrative"]
},
{
"url": "/account",
"state": "supplier.card.account",
"component": "vn-supplier-account",
"description": "Accounts",
"params": {
"supplier": "$ctrl.supplier"
},
"acl": ["administrative"]
},
{
"url": "/address",
"state": "supplier.card.address",
"component": "ui-view",
"abstract": true
},
{
"url": "/index?q",
"state": "supplier.card.address.index",
"component": "vn-supplier-address-index",
"description": "Addresses",
"params": {
"supplier": "$ctrl.supplier"
}
},
{
"url": "/create",
"state": "supplier.card.address.create",
"component": "vn-supplier-address-create",
"description": "New address",
"params": {
"supplier": "$ctrl.supplier"
}
},
{
"url": "/:addressId/edit",
"state": "supplier.card.address.edit",
"component": "vn-supplier-address-edit",
"description": "Edit address"
} }
] ]
} }

View File

@ -0,0 +1,172 @@
<vn-card class="summary">
<h5>
<a ng-if="::$ctrl.summary.id"
vn-tooltip="Go to the supplier"
ui-sref="supplier.card.summary({id: {{::$ctrl.summary.id}}})"
name="goToSummary">
<vn-icon-button icon="launch"></vn-icon-button>
</a>
<span>{{::$ctrl.summary.name}} - {{::$ctrl.summary.id}}</span>
</h5>
<vn-horizontal>
<vn-one>
<h4 ng-show="$ctrl.isAdministrative">
<a
ui-sref="supplier.card.basicData({id:$ctrl.supplier.id})"
target="_self">
<span translate vn-tooltip="Go to">Basic data</span>
</a>
</h4>
<h4
translate
ng-show="!$ctrl.isAdministrative">
Basic data
</h4>
<vn-vertical>
<vn-label-value
label="Id"
value="{{::$ctrl.summary.id}}">
</vn-label-value>
<vn-label-value
label="Alias"
value="{{::$ctrl.summary.nickname}}">
</vn-label-value>
<vn-label-value label="Responsible">
<span
ng-click="workerDescriptor.show($event, $ctrl.summary.workerFk)"
class="link">
{{$ctrl.summary.worker.user.nickname}}
</span>
</vn-label-value>
<vn-label-value no-ellipsize
label="Notes"
value="{{::$ctrl.summary.note}}">
</vn-label-value>
<vn-check
label="Verified"
ng-model="$ctrl.summary.isReal"
disabled="true">
</vn-check>
<vn-check
label="Is active"
ng-model="$ctrl.summary.isActive"
disabled="true">
</vn-check>
</vn-vertical>
</vn-one>
<vn-one>
<h4 ng-show="$ctrl.isAdministrative">
<a
ui-sref="supplier.card.billingData({id:$ctrl.supplier.id})"
target="_self">
<span translate vn-tooltip="Go to">Billing data</span>
</a>
</h4>
<h4
translate
ng-show="!$ctrl.isAdministrative">
Billing data
</h4>
<vn-label-value
label="Pay method"
value="{{::$ctrl.summary.payMethod.name}}">
</vn-label-value>
<vn-label-value
label="Payment deadline"
value="{{::$ctrl.summary.payDem.payDem}}">
</vn-label-value>
<vn-label-value
label="Pay day"
value="{{::$ctrl.summary.payDay}}">
</vn-label-value>
<vn-label-value
label="Account"
value="{{::$ctrl.summary.account}}">
</vn-label-value>
</vn-one>
</vn-horizontal>
<vn-horizontal>
<vn-one>
<h4 ng-show="$ctrl.isAdministrative">
<a
ui-sref="supplier.card.fiscalData({id:$ctrl.supplier.id})"
target="_self">
<span translate vn-tooltip="Go to">Fiscal data</span>
</a>
</h4>
<h4
translate
ng-show="!$ctrl.isAdministrative">
Fiscal data
</h4>
<vn-label-value
label="Sage tax type"
value="{{::$ctrl.summary.sageTaxType.vat}}">
</vn-label-value>
<vn-label-value
title="{{::$ctrl.summary.sageTransactionType.transaction}}"
label="Sage transaction type"
value="{{::$ctrl.summary.sageTransactionType.transaction}}">
</vn-label-value>
<vn-label-value
title="{{::$ctrl.summary.sageWithholding.withholding}}"
label="Sage withholding"
value="{{::$ctrl.summary.sageWithholding.withholding}}">
</vn-label-value>
<vn-label-value
label="Supplier activity"
value="{{::$ctrl.summary.supplierActivity.name}}">
</vn-label-value>
<vn-label-value
label="Healt register"
value="{{::$ctrl.summary.healthRegister}}">
</vn-one>
</vn-horizontal>
<vn-horizontal>
<vn-one>
<h4 ng-show="$ctrl.isAdministrative">
<a
ui-sref="supplier.card.fiscalData({id:$ctrl.supplier.id})"
target="_self">
<span translate vn-tooltip="Go to">Fiscal address</span>
</a>
</h4>
<h4
translate
ng-show="!$ctrl.isAdministrative">
Fiscal address
</h4>
<vn-label-value
label="Social name"
value="{{::$ctrl.summary.name}}">
</vn-label-value>
<vn-label-value
label="Tax number"
value="{{::$ctrl.summary.nif}}">
</vn-label-value>
<vn-label-value
label="Street"
value="{{::$ctrl.summary.street}}">
</vn-label-value>
<vn-label-value
label="City"
value="{{::$ctrl.summary.city}}">
</vn-label-value>
<vn-label-value
label="Postcode"
value="{{::$ctrl.summary.postCode}}">
</vn-label-value>
<vn-label-value
label="Province"
value="{{::$ctrl.summary.province.name}}">
</vn-label-value>
<vn-label-value
label="Country"
value="{{::$ctrl.summary.country.name}}">
</vn-label-value>
</vn-one>
</vn-horizontal>
</vn-card>
<vn-worker-descriptor-popover
vn-id="workerDescriptor">
</vn-worker-descriptor-popover>

View File

@ -0,0 +1,30 @@
import ngModule from '../module';
import Summary from 'salix/components/summary';
import './style.scss';
class Controller extends Summary {
$onChanges() {
if (!this.supplier)
return;
this.getSummary();
}
get isAdministrative() {
return this.aclService.hasAny(['administrative']);
}
getSummary() {
return this.$http.get(`Suppliers/${this.supplier.id}/getSummary`).then(response => {
this.summary = response.data;
});
}
}
ngModule.vnComponent('vnSupplierSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
supplier: '<'
}
});

View File

@ -0,0 +1,7 @@
@import "variables";
vn-client-summary {
.alert span {
color: $color-alert
}
}