Skip to content

Commit 0602be7

Browse files
committed
Fix reading of asset type from schema
Retain backwards compatibility
1 parent af8e8d5 commit 0602be7

5 files changed

Lines changed: 19 additions & 10 deletions

File tree

frontend/src/modules/assetManagement/views/assetManagementModalView.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ define(function(require) {
1616
postRender: function() {
1717
this.setupSubViews();
1818
this.setupFilterAndSearchView();
19-
if (this.options.assetType === "Asset:image" && Origin.scaffold.getCurrentModel().get('_component') === 'graphic') {
19+
if (this.options.assetType === "image" && Origin.scaffold.getCurrentModel().get('_component') === 'graphic') {
2020
this.setupImageAutofillButton();
2121
}
2222
this.resizePanels();
2323
},
2424

2525
setupSubViews: function() {
2626
this.search = {};
27-
// Replace Asset and : so we can have both filtered and all asset types
28-
var assetType = this.options.assetType.replace('Asset', '').replace(':', '');
27+
28+
var assetType = this.options.assetType;
2929

3030
if (assetType) {
3131
var filters = [assetType];

frontend/src/modules/editor/themeEditor/views/editorThemingView.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,10 @@ define(function(require) {
210210
if (!fieldView) {
211211
return;
212212
}
213-
if (fieldView.schema.inputType === 'ColourPicker') {
213+
var inputType = fieldView.schema.inputType.type || fieldView.schema.inputType;
214+
if (inputType === 'ColourPicker') {
214215
fieldView.setValue(value);
215-
} else if (typeof fieldView.schema.inputType === 'string' && fieldView.schema.inputType.indexOf('Asset:') > -1) {
216+
} else if (inputType.indexOf('Asset') > -1) {
216217
fieldView.setValue(value);
217218
fieldView.render();
218219
$('div[data-editor-id*="' + key + '"]').append(fieldView.editor.$el);

frontend/src/modules/scaffold/views/scaffoldAssetItemView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ define([
174174

175175
Origin.trigger('modal:open', AssetManagementModalView, {
176176
collection: new AssetCollection,
177-
assetType: 'Asset:image',
177+
assetType: 'image',
178178
_shouldShowScrollbar: false,
179179
onUpdate: function(data) {
180180
if (!data) return;

frontend/src/modules/scaffold/views/scaffoldAssetView.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ define([
1010

1111
var ScaffoldAssetView = Backbone.Form.editors.Base.extend({
1212

13+
assetType: null,
14+
1315
events: {
1416
'change input': function() { this.trigger('change', this); },
1517
'focus input': function() { this.trigger('focus', this); },
@@ -52,9 +54,13 @@ define([
5254
var inputType = this.schema.inputType;
5355
var dataUrl = Helpers.isAssetExternal(this.value) ? this.value : '';
5456

57+
this.assetType = typeof inputType === 'string' ?
58+
inputType.replace(/Asset|:/g, '') :
59+
inputType.media;
60+
5561
this.$el.html(Handlebars.templates[this.constructor.template]({
5662
value: this.value,
57-
type: inputType.media || inputType.replace('Asset:', ''),
63+
type: this.assetType,
5864
url: id ? 'api/asset/serve/' + id : dataUrl,
5965
thumbUrl: id ? 'api/asset/thumb/' + id : dataUrl
6066
}));
@@ -200,7 +206,7 @@ define([
200206

201207
Origin.trigger('modal:open', AssetManagementModalView, {
202208
collection: new AssetCollection,
203-
assetType: this.schema.inputType,
209+
assetType: this.assetType,
204210
_shouldShowScrollbar: false,
205211
onUpdate: function(data) {
206212
if (!data) return;

lib/outputmanager.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,11 +607,13 @@ OutputPlugin.prototype.writeThemeVariables = function(courseId, theme, themeVari
607607
function(seriesCallback) {
608608
// Create LESS for properties
609609
async.each(Object.keys(props), function(prop, innerCallback) {
610+
var themeProperty = theme.properties.variables[prop];
611+
var inputType = themeProperty.inputType;
610612
// Check if the user has customised any properties
611-
if (savedSettings.hasOwnProperty(prop) && theme.properties.variables[prop].default !== savedSettings[prop]) {
613+
if (savedSettings.hasOwnProperty(prop) && themeProperty.default !== savedSettings[prop]) {
612614
// The user has customised this property
613615
// Check if processing an image asset
614-
if (theme.properties.variables[prop].inputType === 'Asset:image') {
616+
if (inputType.media === 'image' || inputType === 'Asset:image') {
615617
// Split the path so we can process the filename
616618
var assetPathArray = savedSettings[prop].split('/');
617619
// Encode the filename (removing spaces, etc.)

0 commit comments

Comments
 (0)