FIX: Fix delete button for Tag Groups. (#6965)

This commit is contained in:
Bianca Nenciu 2019-02-04 13:46:39 +02:00 committed by Régis Hanol
parent 0337622420
commit e0e91fad87
3 changed files with 42 additions and 1 deletions

View File

@ -9,6 +9,11 @@ export default RestModel.extend({
return saving || Ember.isEmpty(name) || Ember.isEmpty(tagNames);
},
@computed("id")
disableDelete(id) {
return !parseInt(id);
},
@computed("permissions")
permissionName: {
get(permissions) {

View File

@ -44,6 +44,6 @@
</section>
<button {{action "save"}} disabled={{model.disableSave}} class='btn btn-default'>{{i18n 'tagging.groups.save'}}</button>
<button {{action "destroy"}} disabled={{model.disableSave}} class='btn btn-danger'>{{d-icon "far-trash-alt"}} {{i18n 'tagging.groups.delete'}}</button>
<button {{action "destroy"}} disabled={{model.disableDelete}} class='btn btn-danger'>{{d-icon "far-trash-alt"}} {{i18n 'tagging.groups.delete'}}</button>
<span class="saving {{unless model.savingStatus 'hidden'}}">{{model.savingStatus}}</span>
</div>

View File

@ -0,0 +1,36 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Tag Groups", {
loggedIn: true,
settings: { tagging_enabled: true },
pretend(server, helper) {
server.post("/tag_groups", () => {
return helper.response({
tag_group: {
id: 42,
name: "test tag group",
tag_names: ["monkey"],
parent_tag_name: [],
one_per_topic: false,
permissions: { everyone: 1 }
}
});
});
}
});
QUnit.test("tag groups can be saved and deleted", async assert => {
const tags = selectKit(".tag-chooser");
await visit("/tag_groups");
await click(".content-list .btn");
await fillIn(".tag-group-content h1 input", "test tag group");
await tags.expand();
await tags.selectRowByValue("monkey");
await click(".tag-group-content .btn.btn-default");
await click(".tag-chooser .choice:first");
assert.ok(!find(".tag-group-content .btn.btn-danger")[0].disabled);
});