terrier-engine 4.36.8 → 4.37.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.
@@ -47,7 +47,7 @@ const updatedKey = Messages.typedKey<TableRef>()
47
47
  ////////////////////////////////////////////////////////////////////////////////
48
48
 
49
49
  /**
50
- * Recursively collects all of the filters for this and all joined tables.
50
+ * Recursively collect s all of the filters for this and all joined tables.
51
51
  * Only keep one (the last one traversed) per table/column combination.
52
52
  * This means that some filters may clobber others, but I think it will yield
53
53
  * the desired result most of the time.
@@ -82,6 +82,8 @@ export class TableView<T extends TableRef> extends ContentPart<{ schema: SchemaD
82
82
  modelDef!: ModelDef
83
83
  parentView?: TableView<any>
84
84
 
85
+ joinParts: Record<string, TableView<JoinedTableRef>> = {}
86
+
85
87
  editTableKey = Messages.untypedKey()
86
88
  editColumnsKey = Messages.untypedKey()
87
89
  editFiltersKey = Messages.untypedKey()
@@ -95,7 +97,11 @@ export class TableView<T extends TableRef> extends ContentPart<{ schema: SchemaD
95
97
  this.modelDef = this.schema.models[this.table.model]
96
98
  this.tableName = inflection.titleize(inflection.tableize(this.table.model))
97
99
  this.displayName = this.tableName
98
- this.updateJoinedViews()
100
+
101
+ // create parts for the existing joins
102
+ Object.values(this.table.joins || {}).map(table => {
103
+ this.addJoinedPart(table)
104
+ })
99
105
 
100
106
  this.onClick(this.editColumnsKey, _ => {
101
107
  log.info(`Edit ${this.displayName} Columns`)
@@ -163,7 +169,8 @@ export class TableView<T extends TableRef> extends ContentPart<{ schema: SchemaD
163
169
  log.info(`Creating joined table`, newTable)
164
170
  this.table.joins ||= {}
165
171
  this.table.joins[newTable.belongs_to] = newTable
166
- this.updateJoinedViews()
172
+ this.addJoinedPart(newTable)
173
+ this.dirty()
167
174
  }
168
175
  }
169
176
  this.app.showModal(JoinedTableEditorModal, {table, belongsTo, callback, parentTable: this.state.table as TableRef})
@@ -171,23 +178,19 @@ export class TableView<T extends TableRef> extends ContentPart<{ schema: SchemaD
171
178
  })
172
179
  }
173
180
 
174
- /**
175
- * Re-generates all views for the joined tables.
176
- */
177
- updateJoinedViews() {
178
- const states = Object.values(this.table.joins || {}).map(table => {
179
- return {schema: this.schema, queryEditor: this.state.queryEditor, table}
180
- })
181
- this.assignCollection('joined', JoinedTableView, states)
182
- for (const part of this.getCollectionParts('joined')) {
183
- (part as JoinedTableView).parentView = this
184
- }
181
+ addJoinedPart(joinedTable: JoinedTableRef) {
182
+ const state = {schema: this.schema, queryEditor: this.state.queryEditor, table: joinedTable}
183
+ const part = this.makePart(JoinedTableView, state)
184
+ part.parentView = this
185
+ this.joinParts[joinedTable.belongs_to] = part
185
186
  }
186
187
 
187
- removeJoinedTable(joinedTable: JoinedTableRef) {
188
+
189
+ removeJoinedPart(joinedTable: JoinedTableRef) {
188
190
  if (this.table?.joins) {
189
191
  delete this.table.joins[joinedTable.belongs_to]
190
- this.updateJoinedViews()
192
+ delete this.joinParts[joinedTable.belongs_to]
193
+ this.dirty()
191
194
  }
192
195
  }
193
196
 
@@ -208,8 +211,11 @@ export class TableView<T extends TableRef> extends ContentPart<{ schema: SchemaD
208
211
  parent.div('.chicken-foot')
209
212
  }
210
213
 
211
- this.renderCollection(parent, 'joined')
212
- .class('joins-column')
214
+ parent.div('.joins-column', col => {
215
+ for (const name of Object.keys(this.joinParts).sort()) {
216
+ col.part(this.joinParts[name])
217
+ }
218
+ })
213
219
 
214
220
  parent.div(".tt-panel.table-panel", panel => {
215
221
  panel.div('.title', title => {
@@ -350,7 +356,7 @@ export class JoinedTableView extends TableView<JoinedTableRef> {
350
356
  }
351
357
  else {
352
358
  log.info(`Deleted joined table ${this.displayName}`)
353
- this.parentView!.removeJoinedTable(this.table)
359
+ this.parentView!.removeJoinedPart(this.table)
354
360
  }
355
361
  }
356
362
  this.app.showModal(JoinedTableEditorModal, {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "files": [
5
5
  "*"
6
6
  ],
7
- "version": "4.36.8",
7
+ "version": "4.37.0",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Terrier-Tech/terrier-engine"