@sumaris-net/ngx-components 21.0.0-rc40 → 21.0.0-rc41

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.
package/doc/changelog.md CHANGED
@@ -2329,3 +2329,4 @@ enh: Environment: add useHash property to configure Angular router to use hash U
2329
2329
  - enh(image-gallery): add support for custom version query param
2330
2330
  - enh(image-gallery): emit `modeChange` when gallery mode updates
2331
2331
  - fix(menu) Rename getter `MenuService.enabled: `Observable<boolean>` into `enabled$`, and add `get enabled(): boolean`
2332
+ - enh(theme) Allow overriding configuration properties (e.g. `sumaris.color.*` theme colors) using the injected `ENVIRONMENT` token's new `properties` field - useful to customize the app without a server-side (Pod) configuration, e.g. for offline apps on mobile
@@ -234,6 +234,11 @@ class Environment {
234
234
  account;
235
235
  entityEditor;
236
236
  feed;
237
+ // Configuration options (same keys as the server's Pod configuration - e.g. 'sumaris.color.primary'),
238
+ // Used to override, or replace, the config loaded from the server (e.g. useful for offline mobile apps,
239
+ // or to fully customize the app without any server-side configuration).
240
+ // See CORE_CONFIG_OPTIONS for the list of existing keys.
241
+ properties;
237
242
  }
238
243
 
239
244
  const DATE_ISO_PATTERN = 'YYYY-MM-DDTHH:mm:ss.SSSZ';
@@ -17377,6 +17382,12 @@ const environment = Object.freeze({
17377
17382
  maxCount: 3,
17378
17383
  },
17379
17384
  buildDate: new Date().toISOString(),
17385
+ // Example: override (or replace) server (Pod) configuration properties - e.g. theme colors -
17386
+ // directly from the environment. Useful to customize the app without any server-side
17387
+ // configuration (e.g. offline apps, on mobile). See CORE_CONFIG_OPTIONS for existing keys.
17388
+ //properties: {
17389
+ // 'sumaris.color.primary': '#5b5ef4',
17390
+ //},
17380
17391
  });
17381
17392
 
17382
17393
  class EntityClasses {
@@ -26084,6 +26095,8 @@ class ConfigService extends BaseGraphqlService {
26084
26095
  // If this is the default config
26085
26096
  const defaultConfig = this.$data.value;
26086
26097
  if (isNotNil(defaultConfig) && reloadedConfig?.label === defaultConfig.label) {
26098
+ // Re-apply environment properties (e.g. theme colors), so they are not lost on save
26099
+ this.mergeEnvironmentProperties(reloadedConfig);
26087
26100
  // Emit update event when is default config
26088
26101
  this.$data.next(reloadedConfig);
26089
26102
  }
@@ -26158,12 +26171,28 @@ class ConfigService extends BaseGraphqlService {
26158
26171
  data.label = data.label || this.environment.name;
26159
26172
  // Reset name (if same as label)
26160
26173
  data.name = data.name !== data.label ? data.name : undefined;
26174
+ // Merge environment properties (e.g. theme colors), to allow customizing the app
26175
+ // without a server-side configuration (useful for offline apps, on mobile)
26176
+ this.mergeEnvironmentProperties(data);
26161
26177
  // Check compatible version
26162
26178
  if (wasJustLoaded) {
26163
26179
  // TODO
26164
26180
  }
26165
26181
  return data;
26166
26182
  }
26183
+ /**
26184
+ * Merge the environment's properties (if any) into the given configuration.
26185
+ * Environment properties take precedence over the server (Pod) configuration,
26186
+ * so the app can be fully customized (e.g. theme colors) using only the injected
26187
+ * ENVIRONMENT token - without requiring any change on the server side.
26188
+ */
26189
+ mergeEnvironmentProperties(data) {
26190
+ const envProperties = this.environment.properties;
26191
+ if (envProperties && Object.keys(envProperties).length) {
26192
+ data.properties = { ...data.properties, ...envProperties };
26193
+ }
26194
+ return data;
26195
+ }
26167
26196
  async restoreLocally() {
26168
26197
  let data;
26169
26198
  // Try to load from local storage