@smartsoft001/crud-shell-angular 2.155.0 → 2.157.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.
@@ -3042,9 +3042,10 @@ class CrudItemPageBaseComponent extends BaseComponent$1 {
3042
3042
  }
3043
3043
  /**
3044
3044
  * The reactive form of the first rendered `<smart-form>`, or `undefined`
3045
- * until the form factory has built it. A method rather than a `computed`:
3046
- * `FormComponent.form` is a plain field assigned asynchronously, so a
3047
- * computed would cache `undefined` from the first read.
3045
+ * until the form factory has built it. `FormComponent.form` is a getter over
3046
+ * a signal, so it always reports the group currently rendered; a method is
3047
+ * kept here so the page button handlers read that group at call time rather
3048
+ * than through a `computed` captured when the form did not exist yet.
3048
3049
  */
3049
3050
  getForm() {
3050
3051
  return this.formComponents()[0]?.form;
@@ -3228,6 +3229,31 @@ class ItemComponent extends CreateDynamicComponent('crud-item-page') {
3228
3229
  this.detailsService.init();
3229
3230
  this.styleService.init(this.elementRef);
3230
3231
  this.pageService.checkPermissions();
3232
+ // The provider has to be in place before the first render: it is part of
3233
+ // the form options, so setting it later hands `smart-form` a new options
3234
+ // object and the group is built a second time. The closure reads `this.id`
3235
+ // lazily, so it can be installed before the route params arrive.
3236
+ this.uniqueProvider.set(async (values) => {
3237
+ const filter = {
3238
+ query: [],
3239
+ };
3240
+ Object.keys(values).forEach((key) => {
3241
+ filter.query.push({
3242
+ key: key,
3243
+ value: values[key],
3244
+ type: '=',
3245
+ });
3246
+ });
3247
+ if (this.id) {
3248
+ filter.query.push({
3249
+ key: 'id',
3250
+ value: this.id,
3251
+ type: '!=',
3252
+ });
3253
+ }
3254
+ const { totalCount } = await this.service.getList(filter);
3255
+ return !totalCount;
3256
+ });
3231
3257
  if (this.router.routerState.snapshot.url.split('?')[0].endsWith('/add')) {
3232
3258
  this.mode = 'create';
3233
3259
  await this.generateComponents('add');
@@ -3252,27 +3278,6 @@ class ItemComponent extends CreateDynamicComponent('crud-item-page') {
3252
3278
  }
3253
3279
  });
3254
3280
  }
3255
- this.uniqueProvider.set(async (values) => {
3256
- const filter = {
3257
- query: [],
3258
- };
3259
- Object.keys(values).forEach((key) => {
3260
- filter.query.push({
3261
- key: key,
3262
- value: values[key],
3263
- type: '=',
3264
- });
3265
- });
3266
- if (this.id) {
3267
- filter.query.push({
3268
- key: 'id',
3269
- value: this.id,
3270
- type: '!=',
3271
- });
3272
- }
3273
- const { totalCount } = await this.service.getList(filter);
3274
- return !totalCount;
3275
- });
3276
3281
  if (this.config.details) {
3277
3282
  const compiledComponents = await this.dynamicComponentLoader.getComponentsWithFactories({
3278
3283
  components: [