0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-09-20 07:41:11 +02:00

Exclude "Administratoren" Group

Dieser Commit ist enthalten in:
Philipp 2023-04-17 15:46:11 +02:00 committet von GitHub
Ursprung 235ff68133
Commit 092fd10c38
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -4,10 +4,13 @@ import { makeArray } from "discourse-common/lib/helpers";
export default ComboBox.extend({
content: computed("groups.[]", "field.content.[]", function () {
const whitelist = makeArray(this.field.content);
const blacklist = ["Administratoren"]; // Gruppe, die nicht ausgewählt werden kann
const selectedGroups = makeArray(this.field.content); // bereits ausgewählte Gruppen
return this.groups
.filter((group) => {
return !whitelist.length || whitelist.indexOf(group.id) > -1;
return blacklist.indexOf(group.name) === -1 && // Gruppe ist nicht in der Blacklist
(selectedGroups.length === 0 || // wenn keine Gruppen ausgewählt sind
selectedGroups.indexOf(group.id) > -1); // oder Gruppe bereits ausgewählt wurde
})
.map((g) => {
return {
@ -16,4 +19,14 @@ export default ComboBox.extend({
};
});
}),
didInsertElement() {
// Setze alle Gruppen als bereits ausgewählt
this._super(...arguments);
const selectedGroups = makeArray(this.field.content);
const allGroups = this.content.map((g) => g.id);
const unselectedGroups = allGroups.filter((g) => !selectedGroups.includes(g));
this.updateValue([...selectedGroups, ...unselectedGroups]);
},
});