Browse Source

Add setName to Component

fixes-symbols
Artur Arseniev 2 years ago
parent
commit
7b3e87a9fa
  1. 8
      src/dom_components/model/Component.ts
  2. 8
      src/navigator/view/ItemView.ts

8
src/dom_components/model/Component.ts

@ -1347,6 +1347,14 @@ export default class Component extends StyleableModel<ComponentProperties> {
); );
} }
/**
* Update component name.
* @param {String} name New name.
*/
setName(name?: string, opts: SetOptions = {}) {
this.set('custom-name', name, opts);
}
/** /**
* Get the icon string * Get the icon string
* @return {String} * @return {String}

8
src/navigator/view/ItemView.ts

@ -230,22 +230,18 @@ export default class ItemView extends View {
*/ */
handleEditEnd(ev?: KeyboardEvent) { handleEditEnd(ev?: KeyboardEvent) {
ev?.stopPropagation(); ev?.stopPropagation();
const { em, $el, clsNoEdit, clsEdit } = this; const { em, $el, clsNoEdit, clsEdit, model } = this;
const inputEl = this.getInputName(); const inputEl = this.getInputName();
const name = inputEl.textContent!; const name = inputEl.textContent!;
inputEl.scrollLeft = 0; inputEl.scrollLeft = 0;
inputEl[inputProp] = 'false'; inputEl[inputProp] = 'false';
this.setName(name, { component: this.model, propName: 'custom-name' }); model.setName(name);
em.setEditing(false); em.setEditing(false);
$el.find(`.${this.inputNameCls}`).addClass(clsNoEdit).removeClass(clsEdit); $el.find(`.${this.inputNameCls}`).addClass(clsNoEdit).removeClass(clsEdit);
// Ensure to always update the layer name #4544 // Ensure to always update the layer name #4544
this.updateName(); this.updateName();
} }
setName(name: string, { propName }: { propName: string; component?: Component }) {
this.model.set(propName, name);
}
/** /**
* Get the input containing the name of the component * Get the input containing the name of the component
* @return {HTMLElement} * @return {HTMLElement}

Loading…
Cancel
Save