@kodaris/krubble-app-components 1.0.65 → 1.0.67

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.
@@ -345,6 +345,7 @@
345
345
  * @property {KRNavItem[]} nav - Navigation items as JSON array
346
346
  * @property {KRUser} user - User profile data
347
347
  * @property {boolean} navEnabled - Whether to show the nav drawer (menu toggle remains visible when false)
348
+ * @property {'employee'|'customer'} user-type - User type. Customers skip all `/api/system` calls since that endpoint is employee-only. Defaults to 'employee'.
348
349
  *
349
350
  *
350
351
  * TODO
@@ -397,6 +398,10 @@
397
398
  * Menu toggle button remains visible and emits menu-click events.
398
399
  */
399
400
  this.navEnabled = true;
401
+ /**
402
+ * User type. Set to 'customer' to skip all /api/system calls — customers don't have access to that endpoint.
403
+ */
404
+ this.userType = 'employee';
400
405
  /**
401
406
  * Breadcrumbs to display in the subbar
402
407
  */
@@ -406,9 +411,13 @@
406
411
  }
407
412
  connectedCallback() {
408
413
  super.connectedCallback();
409
- this.loadPref();
410
414
  this.installFetchInterceptor();
411
415
  }
416
+ // Attributes are not reflected into properties until after the first update,
417
+ // so loadPref() must run here (not connectedCallback) for user-type to be set.
418
+ firstUpdated() {
419
+ this.loadPref();
420
+ }
412
421
  updated(changedProperties) {
413
422
  super.updated(changedProperties);
414
423
  if (changedProperties.has('nav') && this.nav.length > 0) {
@@ -780,6 +789,8 @@
780
789
  this.pref.nav = {};
781
790
  }
782
791
  savePref() {
792
+ if (this.userType === 'customer')
793
+ return;
783
794
  const url = this.pref.uuid
784
795
  ? `/api/system/preference/json/scaffold/${this.pref.uuid}?global=true`
785
796
  : `/api/system/preference/json/scaffold?global=true`;
@@ -798,6 +809,8 @@
798
809
  });
799
810
  }
800
811
  loadPref() {
812
+ if (this.userType === 'customer')
813
+ return;
801
814
  krubbleHttp.Http.fetch({
802
815
  url: '/api/system/preference/json/scaffold?global=true',
803
816
  method: 'GET',
@@ -2210,6 +2223,9 @@
2210
2223
  __decorate$5([
2211
2224
  n({ type: Boolean, attribute: 'nav-enabled' })
2212
2225
  ], exports.Scaffold.prototype, "navEnabled", void 0);
2226
+ __decorate$5([
2227
+ n({ type: String, attribute: 'user-type' })
2228
+ ], exports.Scaffold.prototype, "userType", void 0);
2213
2229
  __decorate$5([
2214
2230
  n({ type: Array })
2215
2231
  ], exports.Scaffold.prototype, "breadcrumbs", void 0);