@zeedhi/teknisa-components-common 1.47.0 → 1.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <coverage generated="1647901843318" clover="3.2.0">
3
- <project timestamp="1647901843318" name="All files">
2
+ <coverage generated="1648836816548" clover="3.2.0">
3
+ <project timestamp="1648836816548" name="All files">
4
4
  <metrics statements="1193" coveredstatements="1193" conditionals="581" coveredconditionals="581" methods="281" coveredmethods="281" elements="2055" coveredelements="2055" complexity="0" loc="1193" ncloc="1193" packages="17" files="31" classes="31"/>
5
5
  <package name="src">
6
6
  <metrics statements="1" coveredstatements="1" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0"/>
@@ -341,7 +341,7 @@
341
341
  <div class='footer quiet pad2 space-top1 center small'>
342
342
  Code coverage generated by
343
343
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
344
- at Mon Mar 21 2022 19:30:43 GMT-0300 (Brasilia Standard Time)
344
+ at Fri Apr 01 2022 15:13:36 GMT-0300 (Brasilia Standard Time)
345
345
  </div>
346
346
  <script src="prettify.js"></script>
347
347
  <script>
@@ -1,8 +1,9 @@
1
- import { KeyMap, I18n, FormatterParserProvider, Messages, Metadata, DatasourceFactory, RestDatasource, URL, MemoryDatasource, Utils, Loader, DateHelper } from '@zeedhi/core';
2
- import { Form, Button, Tooltip, GridEditable, Grid, ComponentRender, Iterable, Carousel, Loading as Loading$1, ModalService, GridColumnEditable, Report, IterableColumnsButtonController, IterableColumnsButton, TreeGridEditable } from '@zeedhi/common';
1
+ import { KeyMap, I18n, FormatterParserProvider, Messages, Metadata, DatasourceFactory, RestDatasource, URL, MemoryDatasource, Utils, Loader, DateHelper, Http } from '@zeedhi/core';
2
+ import { Form, Button, Tooltip, GridEditable, Grid, ComponentRender, Iterable, Carousel, Loading as Loading$1, ModalService, GridColumnEditable, Report, IterableColumnsButtonController, IterableColumnsButton, TreeGridEditable, List } from '@zeedhi/common';
3
3
  import get from 'lodash.get';
4
4
  import debounce from 'lodash.debounce';
5
5
  import merge from 'lodash.merge';
6
+ import { UserInfo } from '@zeedhi/zd-user-info-common';
6
7
 
7
8
  /**
8
9
  * Form to be used on Crud operations
@@ -3171,6 +3172,422 @@ class TekTreeGrid extends TreeGridEditable {
3171
3172
  }
3172
3173
  }
3173
3174
 
3175
+ class TekUserInfoController {
3176
+ constructor(component) {
3177
+ this.component = component;
3178
+ }
3179
+ get versionInfo() {
3180
+ return this.component.versionInfo;
3181
+ }
3182
+ get name() {
3183
+ var _a;
3184
+ return ((_a = this.versionInfo) === null || _a === void 0 ? void 0 : _a.name) || '';
3185
+ }
3186
+ set name(value) {
3187
+ if (!this.versionInfo)
3188
+ return;
3189
+ this.versionInfo.name = value;
3190
+ }
3191
+ get version() {
3192
+ var _a;
3193
+ return ((_a = this.versionInfo) === null || _a === void 0 ? void 0 : _a.version) || '';
3194
+ }
3195
+ set version(value) {
3196
+ if (!this.versionInfo)
3197
+ return;
3198
+ this.versionInfo.version = value;
3199
+ }
3200
+ get defaultEmail() {
3201
+ return this.component.defaultEmail;
3202
+ }
3203
+ set defaultEmail(value) {
3204
+ this.component.defaultEmail = value;
3205
+ }
3206
+ get hasDefaultEmail() {
3207
+ return !!this.component.defaultEmail;
3208
+ }
3209
+ get hasAboutImage() {
3210
+ return !!this.component.aboutImage;
3211
+ }
3212
+ mergeText(name, version) {
3213
+ return `${name} - <b>${version}</b>`;
3214
+ }
3215
+ get mainVersion() {
3216
+ var _a;
3217
+ if (!((_a = this.versionInfo) === null || _a === void 0 ? void 0 : _a.name) || !this.versionInfo.version)
3218
+ return '';
3219
+ return this.mergeText(this.versionInfo.name, this.versionInfo.version);
3220
+ }
3221
+ getItems(tab) {
3222
+ if (!this.versionInfo)
3223
+ return [];
3224
+ const tabInfo = this.versionInfo[tab];
3225
+ return tabInfo.map((item) => this.mergeText(item.name, item.version));
3226
+ }
3227
+ get frontendItems() {
3228
+ return this.getItems('frontend');
3229
+ }
3230
+ get backendItems() {
3231
+ return this.getItems('backend');
3232
+ }
3233
+ get modulesItems() {
3234
+ return this.getItems('modules');
3235
+ }
3236
+ }
3237
+
3238
+ class TekUserInfo extends UserInfo {
3239
+ constructor(props) {
3240
+ super(props);
3241
+ /**
3242
+ * Data about the application version
3243
+ */
3244
+ this.versionInfo = null;
3245
+ /**
3246
+ * Default email address to be defined in the Report Bug form
3247
+ */
3248
+ this.defaultEmail = '';
3249
+ /**
3250
+ * Url from which the version info will be retrieved
3251
+ */
3252
+ this.versionUrl = '';
3253
+ /**
3254
+ * Path to the image to be shown on about modal
3255
+ */
3256
+ this.aboutImage = '';
3257
+ this.versionInfo = this.getInitValue('versionInfo', props.versionInfo, this.versionInfo);
3258
+ this.defaultEmail = this.getInitValue('defaultEmail', props.defaultEmail, this.defaultEmail);
3259
+ this.versionUrl = this.getInitValue('versionUrl', props.versionUrl, this.versionUrl);
3260
+ this.aboutImage = this.getInitValue('aboutImage', props.aboutImage, this.aboutImage);
3261
+ this.createAccessors();
3262
+ this.propBottomSlot = props.bottomSlot;
3263
+ }
3264
+ getBottomSlot() {
3265
+ return [
3266
+ {
3267
+ name: `${this.name}_bottom_list`,
3268
+ component: 'TekUserInfoList',
3269
+ parentName: this.name,
3270
+ },
3271
+ ];
3272
+ }
3273
+ onAboutClick() {
3274
+ if (!this.aboutModal) {
3275
+ this.aboutModal = ModalService.create({
3276
+ name: `${this.name}_about_modal`,
3277
+ cssClass: 'about-modal',
3278
+ children: [
3279
+ {
3280
+ name: `${this.name}_about_header`,
3281
+ component: 'ZdHeader',
3282
+ color: 'transparent',
3283
+ padless: true,
3284
+ elevation: 0,
3285
+ rightSlot: [
3286
+ {
3287
+ name: `${this.name}_about_close_button`,
3288
+ component: 'ZdModalCloseButton',
3289
+ small: true,
3290
+ modalName: `${this.name}_about_modal`,
3291
+ },
3292
+ ],
3293
+ },
3294
+ {
3295
+ name: `${this.name}_about_row`,
3296
+ component: 'ZdTag',
3297
+ tag: 'div',
3298
+ cssClass: 'zd-justify-center zd-px-6',
3299
+ isVisible: `{{TekUserInfoController_${this.componentId}.hasAboutImage}}`,
3300
+ children: [
3301
+ {
3302
+ name: `${this.name}_about_image`,
3303
+ component: 'ZdImage',
3304
+ width: '100%',
3305
+ src: this.aboutImage,
3306
+ },
3307
+ ],
3308
+ },
3309
+ {
3310
+ name: `${this.name}_version_tabs`,
3311
+ cssClass: 'zd-pt-3',
3312
+ component: 'ZdTabs',
3313
+ tabs: [
3314
+ {
3315
+ name: `${this.name}_version_frontend_tab`,
3316
+ tabTitle: 'Frontend',
3317
+ children: this.getVersionTree('frontend'),
3318
+ },
3319
+ {
3320
+ name: `${this.name}_version_backend_tab`,
3321
+ tabTitle: 'Backend',
3322
+ children: this.getVersionTree('backend'),
3323
+ },
3324
+ {
3325
+ name: `${this.name}_version_modules_tab`,
3326
+ tabTitle: 'Modules',
3327
+ children: this.getVersionTree('modules'),
3328
+ },
3329
+ ],
3330
+ },
3331
+ ],
3332
+ });
3333
+ }
3334
+ this.aboutModal.show();
3335
+ }
3336
+ getVersionTree(tab) {
3337
+ if (!this.versionInfo)
3338
+ return [];
3339
+ const main = {
3340
+ name: `${this.name}_version_${tab}_main`,
3341
+ component: 'ZdText',
3342
+ text: `{{TekUserInfoController_${this.componentId}.mainVersion}}`,
3343
+ };
3344
+ const itemsComponent = {
3345
+ name: `${this.name}_version_${tab}`,
3346
+ component: 'ZdText',
3347
+ cssClass: 'zd-pl-4',
3348
+ text: `{{TekUserInfoController_${this.componentId}.${tab}Items}}`,
3349
+ };
3350
+ return [main, itemsComponent];
3351
+ }
3352
+ onReportClick() {
3353
+ if (!this.reportModal) {
3354
+ this.reportModal = ModalService.create({
3355
+ name: `${this.name}_report_modal`,
3356
+ children: [
3357
+ {
3358
+ name: `${this.name}_report_header`,
3359
+ component: 'ZdHeader',
3360
+ color: 'transparent',
3361
+ padless: true,
3362
+ elevation: 0,
3363
+ leftSlot: [
3364
+ {
3365
+ name: `${this.name}_report_title`,
3366
+ component: 'ZdText',
3367
+ text: 'TEKUSERINFO_REPORT_ERROR',
3368
+ cssClass: 'zd-theme-font-title',
3369
+ },
3370
+ ],
3371
+ rightSlot: [
3372
+ {
3373
+ name: `${this.name}_report_close_button`,
3374
+ component: 'ZdModalCloseButton',
3375
+ small: true,
3376
+ modalName: `${this.name}_report_modal`,
3377
+ },
3378
+ ],
3379
+ },
3380
+ {
3381
+ name: `${this.name}_report_form`,
3382
+ component: 'ZdForm',
3383
+ cssClass: 'zd-pt-4',
3384
+ children: [
3385
+ {
3386
+ name: 'report_email',
3387
+ component: 'ZdTextInput',
3388
+ label: 'E-mail',
3389
+ grid: {
3390
+ cols: '12',
3391
+ },
3392
+ value: `{{TekUserInfoController_${this.componentId}.defaultEmail}}`,
3393
+ readonly: `{{TekUserInfoController_${this.componentId}.hasDefaultEmail}}`,
3394
+ validations: {
3395
+ required: {},
3396
+ email: {},
3397
+ },
3398
+ },
3399
+ {
3400
+ name: 'report_cc',
3401
+ component: 'ZdTextInput',
3402
+ label: 'CC',
3403
+ placeholder: 'TEKUSERINFO_EMAIL_PLACEHOLDER',
3404
+ grid: {
3405
+ cols: '12',
3406
+ },
3407
+ },
3408
+ {
3409
+ name: 'report_type',
3410
+ component: 'ZdSelect',
3411
+ label: 'TEKUSERINFO_TYPE',
3412
+ dataValue: 'value',
3413
+ dataText: 'text',
3414
+ datasource: {
3415
+ uniqueKey: 'value',
3416
+ translate: true,
3417
+ data: [
3418
+ { value: '0', text: 'TEKUSERINFO_ERROR' },
3419
+ { value: '1', text: 'TEKUSERINFO_IMPROVEMENT' },
3420
+ ],
3421
+ },
3422
+ grid: {
3423
+ cols: '12',
3424
+ },
3425
+ validations: {
3426
+ required: {},
3427
+ },
3428
+ },
3429
+ {
3430
+ name: 'report_description',
3431
+ component: 'ZdTextarea',
3432
+ label: 'TEKUSERINFO_DESCRIPTION',
3433
+ grid: {
3434
+ cols: '12',
3435
+ },
3436
+ validations: {
3437
+ required: {},
3438
+ },
3439
+ },
3440
+ ],
3441
+ },
3442
+ {
3443
+ name: `${this.name}_report_footer`,
3444
+ component: 'ZdFooter',
3445
+ color: 'transparent',
3446
+ padless: true,
3447
+ rightSlot: [
3448
+ {
3449
+ name: `${this.name}_report_cancel`,
3450
+ component: 'ZdButton',
3451
+ label: 'TEKUSERINFO_CANCEL',
3452
+ outline: true,
3453
+ events: {
3454
+ click: () => { var _a; (_a = this.reportModal) === null || _a === void 0 ? void 0 : _a.hide(); },
3455
+ },
3456
+ },
3457
+ {
3458
+ name: `${this.name}_report_send`,
3459
+ component: 'ZdButton',
3460
+ label: 'TEKUSERINFO_SEND',
3461
+ events: {
3462
+ click: (args) => this.onSendReport(args),
3463
+ },
3464
+ },
3465
+ ],
3466
+ },
3467
+ ],
3468
+ });
3469
+ }
3470
+ this.reportModal.show();
3471
+ }
3472
+ onSendReport({ event, element }) {
3473
+ if (!this.reportModal)
3474
+ return;
3475
+ const form = Metadata.getInstance(`${this.name}_report_form`);
3476
+ if (!form.validate())
3477
+ return;
3478
+ this.callEvent('onSendReport', {
3479
+ event, element, component: this, form,
3480
+ });
3481
+ this.reportModal.hide();
3482
+ }
3483
+ onCreated() {
3484
+ super.onCreated();
3485
+ Loader.addController(`TekUserInfoController_${this.componentId}`, new TekUserInfoController(this));
3486
+ this.bottomSlot = this.propBottomSlot ? this.propBottomSlot : this.getBottomSlot();
3487
+ }
3488
+ onMounted(element) {
3489
+ const _super = Object.create(null, {
3490
+ onMounted: { get: () => super.onMounted }
3491
+ });
3492
+ return __awaiter(this, void 0, void 0, function* () {
3493
+ _super.onMounted.call(this, element);
3494
+ if (this.versionUrl) {
3495
+ const res = yield Http.get(this.versionUrl);
3496
+ this.versionInfo = res.data.versionInfo;
3497
+ }
3498
+ });
3499
+ }
3500
+ }
3501
+ Messages.add({
3502
+ 'pt-BR': {
3503
+ translation: {
3504
+ TEKUSERINFO_ABOUT: 'Sobre',
3505
+ TEKUSERINFO_REPORT_ERROR: 'Reportar Erro',
3506
+ TEKUSERINFO_EMAIL_PLACEHOLDER: 'Separe e-mails usando ";"',
3507
+ TEKUSERINFO_TYPE: 'Tipo',
3508
+ TEKUSERINFO_ERROR: 'Erro',
3509
+ TEKUSERINFO_IMPROVEMENT: 'Melhoria',
3510
+ TEKUSERINFO_DESCRIPTION: 'Descrição',
3511
+ TEKUSERINFO_CANCEL: 'Cancelar',
3512
+ TEKUSERINFO_SEND: 'Enviar',
3513
+ },
3514
+ },
3515
+ 'en-US': {
3516
+ translation: {
3517
+ TEKUSERINFO_ABOUT: 'About',
3518
+ TEKUSERINFO_REPORT_ERROR: 'Report Bug',
3519
+ TEKUSERINFO_EMAIL_PLACEHOLDER: 'Separate e-mails using ";"',
3520
+ TEKUSERINFO_TYPE: 'Type',
3521
+ TEKUSERINFO_ERROR: 'Bug',
3522
+ TEKUSERINFO_IMPROVEMENT: 'Improvement',
3523
+ TEKUSERINFO_DESCRIPTION: 'Description',
3524
+ TEKUSERINFO_CANCEL: 'Cancel',
3525
+ TEKUSERINFO_SEND: 'Send',
3526
+ },
3527
+ },
3528
+ 'es-ES': {
3529
+ translation: {
3530
+ TEKUSERINFO_ABOUT: 'Sobre',
3531
+ TEKUSERINFO_REPORT_ERROR: 'Reportar Error',
3532
+ TEKUSERINFO_EMAIL_PLACEHOLDER: 'Separar e-mails usando ";"',
3533
+ TEKUSERINFO_TYPE: 'Tipo',
3534
+ TEKUSERINFO_ERROR: 'Error',
3535
+ TEKUSERINFO_IMPROVEMENT: 'Mejora',
3536
+ TEKUSERINFO_DESCRIPTION: 'Descripción',
3537
+ TEKUSERINFO_CANCEL: 'Cancelar',
3538
+ TEKUSERINFO_SEND: 'Enviar',
3539
+ },
3540
+ },
3541
+ });
3542
+
3543
+ class TekUserInfoList extends List {
3544
+ constructor(props) {
3545
+ super(props);
3546
+ /**
3547
+ * Name of the user info component
3548
+ */
3549
+ this.parentName = '';
3550
+ this.dense = true;
3551
+ this.parentName = props.parentName || '';
3552
+ this.items = this.getItems();
3553
+ }
3554
+ getItems() {
3555
+ const parent = this.parentName ? Metadata.getInstance(this.parentName) : this.parent;
3556
+ if (!(parent instanceof TekUserInfo)) {
3557
+ throw Error(`Could not find the TekUserInfo component associated with ${this.name} TekUserInfoList`);
3558
+ }
3559
+ return [
3560
+ {
3561
+ name: `${parent.name}_version`,
3562
+ component: 'ZdListItem',
3563
+ title: `{{TekUserInfoController_${parent.componentId}.name}}`,
3564
+ subtitle: `{{TekUserInfoController_${parent.componentId}.version}}`,
3565
+ cssClass: 'zd-px-2',
3566
+ },
3567
+ {
3568
+ name: `${parent.name}_about`,
3569
+ component: 'ZdListItem',
3570
+ title: 'TEKUSERINFO_ABOUT',
3571
+ prependIcon: 'infoOutline',
3572
+ cssClass: 'zd-px-2',
3573
+ events: {
3574
+ click: () => parent.onAboutClick(),
3575
+ },
3576
+ },
3577
+ {
3578
+ name: `${parent.name}_report`,
3579
+ component: 'ZdListItem',
3580
+ title: 'TEKUSERINFO_REPORT_ERROR',
3581
+ prependIcon: 'mdi-ladybug',
3582
+ cssClass: 'zd-px-2',
3583
+ events: {
3584
+ click: () => parent.onReportClick(),
3585
+ },
3586
+ },
3587
+ ];
3588
+ }
3589
+ }
3590
+
3174
3591
  Messages.add({
3175
3592
  'pt-BR': {
3176
3593
  translation: {
@@ -3219,4 +3636,4 @@ Messages.add({
3219
3636
  },
3220
3637
  });
3221
3638
 
3222
- export { BreadcrumbHeader, CardTitle, CrudAddButton, CrudButton, CrudCancelButton, CrudDeleteButton, CrudForm, CrudSaveButton, DynamicFilterOperations, DynamicFilterRelations, Image, IterableCarousel, IterableComponentRender, Loading, Notifications, ProductCard, TekFilterHelper, TekGrid, TekGridColumn, TekGridColumnsButton, TekGridLayoutOptions, TekMemoryDatasource, TekRestDatasource, TekTreeGrid, columnAggregationValues };
3639
+ export { BreadcrumbHeader, CardTitle, CrudAddButton, CrudButton, CrudCancelButton, CrudDeleteButton, CrudForm, CrudSaveButton, DynamicFilterOperations, DynamicFilterRelations, Image, IterableCarousel, IterableComponentRender, Loading, Notifications, ProductCard, TekFilterHelper, TekGrid, TekGridColumn, TekGridColumnsButton, TekGridLayoutOptions, TekMemoryDatasource, TekRestDatasource, TekTreeGrid, TekUserInfo, TekUserInfoList, columnAggregationValues };