-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A few fixes/improvements for the DataSource module #6219
Changes from all commits
0bb9172
c917f03
6b10a77
7b9dc0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
* @extends {Model<DataSourceProps>} | ||
*/ | ||
|
||
import { AddOptions, CombinedModelConstructorOptions, Model, RemoveOptions } from '../../common'; | ||
import { AddOptions, collectionEvents, CombinedModelConstructorOptions, Model, RemoveOptions } from '../../common'; | ||
import EditorModel from '../../editor/model/Editor'; | ||
import { DataRecordProps, DataSourceProps, DataSourceTransformers } from '../types'; | ||
import DataRecord from './DataRecord'; | ||
|
@@ -74,6 +74,7 @@ export default class DataSource extends Model<DataSourceProps> { | |
} | ||
|
||
this.listenTo(this.records, 'add', this.onAdd); | ||
this.listenTo(this.records, collectionEvents, this.handleChanges); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trigger editor updates on data record collection changes. I think some data sources (eg. with data loaded asynchronously) could be updated without triggering any update. |
||
} | ||
|
||
/** | ||
|
@@ -174,4 +175,8 @@ export default class DataSource extends Model<DataSourceProps> { | |
this.records.add(record); | ||
}); | ||
} | ||
|
||
private handleChanges(m: any, c: any, o: any) { | ||
this.em.changesUp(o || c); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,22 +151,11 @@ export default class StyleableModel<T extends ObjectHash = any> extends Model<T> | |
model: this, | ||
em: this.em!, | ||
dataVariable: dataVar, | ||
updateValueFromDataVariable: (newValue: string) => this.updateStyleProp(styleProp, newValue), | ||
updateValueFromDataVariable: () => this.updateView(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to update the model as it's already resolved inside |
||
}); | ||
} | ||
} | ||
|
||
/** | ||
* Update a specific style property | ||
*/ | ||
updateStyleProp(prop: string, value: string) { | ||
const style = this.getStyle(); | ||
style[prop] = value; | ||
this.setStyle(style, { noEvent: true }); | ||
this.trigger(`change:style:${prop}`); | ||
this.updateView(); | ||
} | ||
|
||
getView(frame?: Frame) { | ||
let { views, em } = this; | ||
const frm = frame || em?.getCurrentFrameModel(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trigger editor update on data source collection changes