File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,28 +10,14 @@ define(function(require) {
1010 // Block specific properties
1111 layoutOptions : null ,
1212 dragLayoutOptions : null ,
13- // These are the only attributes which should be permitted on a save
14- // TODO look into this...
15- whitelistAttributes : [
16- '_id' ,
17- '_courseId' ,
18- '_parentId' ,
19- '_layoutOptions' ,
20- '_type' ,
21- '_sortOrder' ,
22- '_classes' ,
23- '_isOptional' ,
24- '_isAvailable' ,
25- 'body' ,
26- 'displayTitle' ,
27- 'title' ,
28- '_extensions' ,
29- 'themeSettings' ,
30- '_onScreen' ,
31- '_isVisible' ,
32- '_isHidden' ,
33- 'instruction' ,
34- '_colorLabel'
13+ attributeBlacklist : [
14+ '_isDeleted' ,
15+ '_tenantId' ,
16+ '_trackingId' ,
17+ 'createdBy' ,
18+ 'createdAt' ,
19+ 'layoutOptions' ,
20+ 'updatedAt'
3521 ]
3622 } ) ;
3723
Original file line number Diff line number Diff line change @@ -6,31 +6,11 @@ define(function(require) {
66 urlRoot : 'api/content/component' ,
77 _parentType : 'block' ,
88 _siblingTypes : 'component' ,
9- // These are the only attributes which should be permitted on a save
10- // TODO look into this...
11- whitelistAttributes : [
12- '_id' ,
13- '_componentType' ,
14- '_courseId' ,
15- '_layout' ,
16- '_parentId' ,
17- '_type' ,
18- 'properties' ,
19- '_component' ,
20- '_extensions' ,
21- '_classes' ,
22- '_isOptional' ,
23- '_isAvailable' ,
24- 'body' ,
25- 'displayTitle' ,
26- 'title' ,
27- 'version' ,
28- 'themeSettings' ,
29- '_onScreen' ,
30- '_isVisible' ,
31- '_isHidden' ,
32- 'instruction' ,
33- '_colorLabel'
9+ attributeBlacklist : [
10+ '_isDeleted' ,
11+ 'createdBy' ,
12+ 'createdAt' ,
13+ 'updatedAt'
3414 ]
3515 } ) ;
3616
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ define(function(require) {
77
88 var ContentModel = Backbone . Model . extend ( {
99 idAttribute : '_id' ,
10- whitelistAttributes : null ,
10+ attributeBlacklist : null ,
1111
1212 initialize : function ( options ) {
1313 this . on ( 'sync' , this . loadedData , this ) ;
@@ -89,17 +89,13 @@ define(function(require) {
8989 return JSON . stringify ( this ) ;
9090 } ,
9191
92- // Remove any attributes which are not on the whitelist (called before a save)
9392 pruneAttributes : function ( ) {
94- var self = this ;
95- // Ensure that only valid attributes are pushed back on the save
96- if ( self . whitelistAttributes ) {
97- _ . each ( _ . keys ( self . attributes ) , function ( key ) {
98- if ( ! _ . contains ( self . whitelistAttributes , key ) ) {
99- self . unset ( key ) ;
100- }
101- } ) ;
102- }
93+ if ( ! this . attributeBlacklist ) return ;
94+ Object . keys ( this . attributes ) . forEach ( function ( key ) {
95+ if ( _ . contains ( this . attributeBlacklist , key ) ) {
96+ this . unset ( key ) ;
97+ }
98+ } , this ) ;
10399 }
104100 } ) ;
105101
You can’t perform that action at this time.
0 commit comments