diff options
| author | neobooru <50623835+neobooru@users.noreply.github.com> | 2020-09-19 22:54:26 +0200 |
|---|---|---|
| committer | neobooru <50623835+neobooru@users.noreply.github.com> | 2020-09-19 22:55:17 +0200 |
| commit | 06ad8b18824e8fe8756fb2e9ed0f3e585be06585 (patch) | |
| tree | 2e549ce94cabf4cae35a17230b519ba5029b3b9d /client/js/models | |
| parent | 1ef0419dc28c52d005693f672f27f6bc107cb277 (diff) | |
client+server: add tag category ordering feature
Fixes #209
Diffstat (limited to 'client/js/models')
| -rw-r--r-- | client/js/models/tag_category.js | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/client/js/models/tag_category.js b/client/js/models/tag_category.js index a8d0e64..cc81f67 100644 --- a/client/js/models/tag_category.js +++ b/client/js/models/tag_category.js @@ -9,10 +9,12 @@ class TagCategory extends events.EventTarget { super(); this._name = ""; this._color = "#000000"; + this._order = 1; this._tagCount = 0; this._isDefault = false; this._origName = null; this._origColor = null; + this._origOrder = null; } get name() { @@ -23,6 +25,10 @@ class TagCategory extends events.EventTarget { return this._color; } + get order() { + return this._order; + } + get tagCount() { return this._tagCount; } @@ -43,6 +49,10 @@ class TagCategory extends events.EventTarget { this._color = value; } + set order(value) { + this._order = value; + } + static fromResponse(response) { const ret = new TagCategory(); ret._updateFromResponse(response); @@ -58,6 +68,9 @@ class TagCategory extends events.EventTarget { if (this.color !== this._origColor) { detail.color = this.color; } + if (this.order !== this._origOrder) { + detail.order = this.order; + } if (!Object.keys(detail).length) { return Promise.resolve(); @@ -65,9 +78,9 @@ class TagCategory extends events.EventTarget { let promise = this._origName ? api.put( - uri.formatApiLink("tag-category", this._origName), - detail - ) + uri.formatApiLink("tag-category", this._origName), + detail + ) : api.post(uri.formatApiLink("tag-categories"), detail); return promise.then((response) => { @@ -104,10 +117,12 @@ class TagCategory extends events.EventTarget { this._version = response.version; this._name = response.name; this._color = response.color; + this._order = response.order; this._isDefault = response.default; this._tagCount = response.usages; this._origName = this.name; this._origColor = this.color; + this._origOrder = this.order; } } |