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

21
src/style_manager/view/PropertyFileView.js

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

Loading…
Cancel
Save