From 0d9ce2ab95d38785db2f75a0449dfdf56626a613 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Wed, 6 Dec 2017 22:58:10 +0100 Subject: [PATCH] Add removeSector in StyleManager --- src/style_manager/index.js | 26 ++++++++++++-------------- src/style_manager/view/SectorView.js | 1 + 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/style_manager/index.js b/src/style_manager/index.js index 7047bf329..469e608e2 100644 --- a/src/style_manager/index.js +++ b/src/style_manager/index.js @@ -1,18 +1,4 @@ /** - * - * * [addSector](#addsector) - * * [getSector](#getsector) - * * [getSectors](#getsectors) - * * [addProperty](#addproperty) - * * [getProperty](#getproperty) - * * [getProperties](#getproperties) - * * [getModelToStyle](#getmodeltostyle) - * * [addType](#addtype) - * * [getType](#gettype) - * * [getTypes](#gettypes) - * * [createType](#createtype) - * * [render](#render) - * * With Style Manager you basically build categories (called sectors) of CSS properties which could * be used to custom components and classes. * You can init the editor with all sectors and properties via configuration @@ -146,6 +132,18 @@ module.exports = () => { }, + /** + * Remove a sector by id + * @param {string} id Sector id + * @return {Sector} Removed sector + * @example + * const removed = styleManager.removeSector('mySector'); + */ + removeSector(id) { + return this.getSectors().remove(this.getSector(id)); + }, + + /** * Get all sectors * @return {Sectors} Collection of sectors diff --git a/src/style_manager/view/SectorView.js b/src/style_manager/view/SectorView.js index f80da44e3..336866a0e 100644 --- a/src/style_manager/view/SectorView.js +++ b/src/style_manager/view/SectorView.js @@ -23,6 +23,7 @@ module.exports = Backbone.View.extend({ const model = this.model; this.listenTo(model, 'change:open', this.updateOpen); this.listenTo(model, 'updateVisibility', this.updateVisibility); + this.listenTo(model, 'destroy remove', this.remove); }, /**