refs #5394 wip generate html code by javascript
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alexandre Riera 2023-06-15 14:14:57 +02:00
parent b167581be7
commit f5f54e99dc
2 changed files with 17 additions and 22 deletions

View File

@ -213,25 +213,4 @@
</vn-date-picker> </vn-date-picker>
</form> </form>
</vn-side-menu> </vn-side-menu>
<vn-worker-descriptor-popover vn-id="Worker"> <div id="descriptors"></div>
</vn-worker-descriptor-popover>
<vn-client-descriptor-popover vn-id="Client">
</vn-client-descriptor-popover>
<vn-entry-descriptor-popover vn-id="Entry">
</vn-entry-descriptor-popover>
<vn-item-descriptor-popover vn-id="Item">
</vn-item-descriptor-popover>
<vn-ticket-descriptor-popover vn-id="Ticket">
</vn-ticket-descriptor-popover>
<vn-zone-descriptor-popover vn-id="Zone">
</vn-zone-descriptor-popover>
<vn-travel-descriptor-popover vn-id="Travel">
</vn-travel-descriptor-popover>
<vn-supplier-descriptor-popover vn-id="Supplier">
</vn-supplier-descriptor-popover>
<vn-route-descriptor-popover vn-id="Route">
</vn-route-descriptor-popover>
<vn-invoice-out-descriptor-popover vn-id="InvoiceOut">
</vn-invoice-out-descriptor-popover>
<vn-invoice-in-descriptor-popover vn-id="InvoiceIn">
</vn-invoice-in-descriptor-popover>

View File

@ -9,6 +9,7 @@ export default class Controller extends Section {
constructor($element, $) { constructor($element, $) {
super($element, $); super($element, $);
this.descriptors = new Map(); this.descriptors = new Map();
this.activeDescriptors = [];
this.hashToColor = hashToColor; this.hashToColor = hashToColor;
this.actionsText = { this.actionsText = {
insert: 'Creates', insert: 'Creates',
@ -93,10 +94,23 @@ export default class Controller extends Section {
val: getVal(vals, prop), val: getVal(vals, prop),
descriptor descriptor
}); });
if (descriptor && !this.activeDescriptors.includes(descriptor))
this.activeDescriptors.push(descriptor);
} }
log.props.sort( log.props.sort(
(a, b) => a.nameI18n.localeCompare(b.nameI18n)); (a, b) => a.nameI18n.localeCompare(b.nameI18n));
} }
let innerHTML = '';
for (const descriptor of this.activeDescriptors)
innerHTML += `<vn-${this.toKebabCase(descriptor)}-descriptor-popover vn-id="${descriptor}"></vn-${this.toKebabCase(descriptor)}-descriptor-popover>\n`;
document.getElementById('descriptors').innerHTML = innerHTML;
}
toKebabCase(str) {
return str.replace(/\s+/g, '-')
.replace(/([a-z])([A-Z])/g, '$1-$2')
.toLowerCase();
function getVal(vals, prop) { function getVal(vals, prop) {
let val; let id; let val; let id;
@ -275,6 +289,8 @@ function firstUpper(str) {
return str && str.charAt(0).toUpperCase() + str.substr(1); return str && str.charAt(0).toUpperCase() + str.substr(1);
} }
Controller.$inject = ['$element', '$scope', '$compile'];
ngModule.vnComponent('vnLog', { ngModule.vnComponent('vnLog', {
controller: Controller, controller: Controller,
template: require('./index.html'), template: require('./index.html'),