@nauticana/sail 0.5.1 → 0.5.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nauticana/sail",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Metadata-driven Angular component library for CRUD admin frontends backed by the keel Go backend. Tables, forms, navigation, OTP/2FA/social auth, billing.",
5
5
  "main": "src/index.ts",
6
6
  "files": [
@@ -50,7 +50,7 @@ export class TableSearch extends BaseForm implements OnInit {
50
50
  }
51
51
  });
52
52
  }
53
- this.editableRecord = this.emptyRecord();
53
+ this.editableRecord = this.emptySearchRecord();
54
54
  this.searchColumns = this.getDisplayedColumns();
55
55
  }
56
56
 
@@ -63,7 +63,33 @@ export class TableSearch extends BaseForm implements OnInit {
63
63
  }
64
64
 
65
65
  onClear() {
66
- this.editableRecord = this.emptyRecord();
66
+ this.editableRecord = this.emptySearchRecord();
67
+ }
68
+
69
+ /**
70
+ * Search-form variant of `emptyRecord()`. Boolean columns are forced to
71
+ * null so an unmodified Search click does not coerce filters from the
72
+ * table's HasDefault value (e.g. an `is_primary` column with a `FALSE`
73
+ * default would otherwise have the form submit `?IsPrimary=false` and
74
+ * silently exclude every primary-flag row).
75
+ *
76
+ * The user opts into a boolean filter by clicking the checkbox: first
77
+ * click sets it to `true`, a second click sets it to `false`, and the
78
+ * Clear button resets back to `null` (no filter). `buildSearchTerms`
79
+ * already skips `null` / `undefined` values, so the URL only carries
80
+ * filters the user explicitly toggled.
81
+ */
82
+ private emptySearchRecord(): any {
83
+ const rec = this.emptyRecord();
84
+ const tableDef = this.cacheService.getTableDefinition(this.tableName);
85
+ if (tableDef?.Columns) {
86
+ for (const col of tableDef.Columns) {
87
+ if (col.DataType === 'boolean') {
88
+ rec[col.PascalName] = null;
89
+ }
90
+ }
91
+ }
92
+ return rec;
67
93
  }
68
94
 
69
95
  onAddRecord() {