Browse Source

Fix the `open-assets` call in Style Manager. Closes #1241

pull/1359/head
Artur Arseniev 8 years ago
parent
commit
7de87a15e4
  1. 15
      src/asset_manager/view/AssetImageView.js
  2. 21
      src/style_manager/view/PropertyFileView.js

15
src/asset_manager/view/AssetImageView.js

@ -1,3 +1,5 @@
import { isFunction } from 'underscore';
module.exports = require('./AssetView').extend({ module.exports = require('./AssetView').extend({
events: { events: {
'click [data-toggle=asset-remove]': 'onRemove', 'click [data-toggle=asset-remove]': 'onRemove',
@ -44,7 +46,7 @@ module.exports = require('./AssetView').extend({
this.collection.trigger('deselectAll'); this.collection.trigger('deselectAll');
this.$el.addClass(this.pfx + 'highlight'); this.$el.addClass(this.pfx + 'highlight');
if (typeof onClick === 'function') { if (isFunction(onClick)) {
onClick(model); onClick(model);
} else { } else {
this.updateTarget(this.collection.target); this.updateTarget(this.collection.target);
@ -56,11 +58,10 @@ module.exports = require('./AssetView').extend({
* @private * @private
* */ * */
onDblClick() { onDblClick() {
const em = this.em; const { em, model } = this;
var onDblClick = this.config.onDblClick; const onDblClick = this.config.onDblClick;
var model = this.model;
if (typeof onDblClick === 'function') { if (isFunction(onDblClick)) {
onDblClick(model); onDblClick(model);
} else { } else {
this.updateTarget(this.collection.target); this.updateTarget(this.collection.target);
@ -68,9 +69,7 @@ module.exports = require('./AssetView').extend({
} }
var onSelect = this.collection.onSelect; var onSelect = this.collection.onSelect;
if (typeof onSelect == 'function') { isFunction(onSelect) && onSelect(model);
onSelect(this.model);
}
}, },
/** /**

21
src/style_manager/view/PropertyFileView.js

@ -113,19 +113,20 @@ module.exports = PropertyView.extend({
* @return void * @return void
* */ * */
openAssetManager(e) { openAssetManager(e) {
var that = this; const that = this;
var em = this.em; const { em, modal } = this;
var editor = em ? em.get('Editor') : ''; const editor = em ? em.get('Editor') : '';
if (editor) { if (editor) {
this.modal.setTitle('Select image');
this.modal.setContent(this.am.getContainer());
this.am.setTarget(null);
editor.runCommand('open-assets', { editor.runCommand('open-assets', {
target: this.model, types: ['image'],
onSelect(target) { accept: 'image/*',
that.modal.close(); target: this.getTargetModel(),
that.spreadUrl(target.get('src')); onClick() {},
onDblClick() {},
onSelect(asset) {
modal.close();
that.spreadUrl(asset.get('src'));
} }
}); });
} }

Loading…
Cancel
Save