Browse Source

Allow to pass `el` prop to Buttons from Panels module

pull/3147/head
Artur Arseniev 5 years ago
parent
commit
f59bfa2c3e
  1. 21
      src/panels/view/ButtonView.js
  2. 11
      src/panels/view/ButtonsView.js

21
src/panels/view/ButtonView.js

@ -89,6 +89,8 @@ export default Backbone.View.extend({
const commandName = model.get('command');
let command = {};
if (!commandName) return;
if (commands && isString(commandName)) {
command = commands.get(commandName) || {};
} else if (isFunction(commandName)) {
@ -133,15 +135,15 @@ export default Backbone.View.extend({
* @return void
* */
clicked(e) {
if (this.model.get('bntsVis')) return;
if (this.model.get('disable')) return;
const { model } = this;
if (model.get('bntsVis') || model.get('disable') || !model.get('command'))
return;
this.toggleActive();
},
toggleActive() {
const { model } = this;
const { model, em } = this;
const { active, togglable } = model.attributes;
if (active && !togglable) return;
@ -149,19 +151,18 @@ export default Backbone.View.extend({
model.set('active', !active);
// If the stop is requested
var command = this.em.get('Commands').get('select-comp');
if (active) {
if (model.get('runDefaultCommand')) this.em.runDefault();
if (model.get('runDefaultCommand')) em.runDefault();
} else {
if (model.get('stopDefaultCommand')) this.em.stopDefault();
if (model.get('stopDefaultCommand')) em.stopDefault();
}
},
render() {
const label = this.model.get('label');
const { model } = this;
const label = model.get('label');
const { $el } = this;
$el.empty();
!model.get('el') && $el.empty();
this.updateAttributes();
label && $el.append(label);
this.checkActive();

11
src/panels/view/ButtonsView.js

@ -31,15 +31,16 @@ export default Backbone.View.extend({
* @return Object Object created
* */
addToCollection(model, fragmentEl) {
var fragment = fragmentEl || null;
var viewObject = ButtonView;
var view = new viewObject({
const fragment = fragmentEl || null;
const viewObject = ButtonView;
const el = model.get('el');
const view = new viewObject({
el,
model,
config: this.config,
parentM: this.parentM
});
var rendered = view.render().el;
const rendered = view.render().el;
if (fragment) {
fragment.appendChild(rendered);

Loading…
Cancel
Save