Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-10 04:12:53 +01:00
Show but differentiate unsubbed action options
Dieser Commit ist enthalten in:
Ursprung
a13096c8f1
Commit
a42e23d352
8 geänderte Dateien mit 61 neuen und 13 gelöschten Zeilen
|
@ -1,6 +1,7 @@
|
|||
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
||||
import wizardSchema, {
|
||||
actionsAvailableWithAdditionalSubscription,
|
||||
actionsAvailableWithCurrentSubscription
|
||||
} from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
|
||||
import { empty, equal, or } from "@ember/object/computed";
|
||||
import { notificationLevels, selectKitContent } from "../lib/wizard";
|
||||
|
@ -100,11 +101,16 @@ export default Component.extend(UndoChanges, {
|
|||
actionTypes(subscribed, subscription) {
|
||||
let unsubscribedActions =
|
||||
actionsAvailableWithAdditionalSubscription(subscription);
|
||||
let subscribedActions = actionsAvailableWithCurrentSubscription(subscription);
|
||||
return Object.keys(wizardSchema.action.types).reduce((result, type) => {
|
||||
let subscriptionLabel = (subscribedActions.includes(type) || unsubscribedActions.includes(type));
|
||||
let disabled = unsubscribedActions.includes(type);
|
||||
console.log(subscriptionLabel, disabled);
|
||||
result.push({
|
||||
id: type,
|
||||
name: I18n.t(`admin.wizard.action.${type}.label`),
|
||||
subscribed: unsubscribedActions.includes(type),
|
||||
subscription: subscriptionLabel,
|
||||
disabled: disabled,
|
||||
});
|
||||
return result;
|
||||
}, []);
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
import SelectKitRowComponent from "select-kit/components/select-kit/select-kit-row";
|
||||
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
||||
|
||||
export default SelectKitRowComponent.extend();
|
||||
export default SelectKitRowComponent.extend({
|
||||
classNameBindings: ["isDisabled:disabled"],
|
||||
|
||||
@discourseComputed("item")
|
||||
isDisabled() {
|
||||
return this.item.disabled;
|
||||
},
|
||||
|
||||
click(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (!this.item.disabled) {
|
||||
this.selectKit.select(this.rowValue, this.item);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -201,8 +201,8 @@ const action = {
|
|||
"send_to_api",
|
||||
],
|
||||
actionTypesWithSubscription: {
|
||||
advanced: ["send_message", "add_to_group", "watch_categories"],
|
||||
business: ["create_category", "create_group", "send_to_api"],
|
||||
basic: ["send_message", "add_to_group", "watch_categories"],
|
||||
advanced: ["create_category", "create_group", "send_to_api"],
|
||||
},
|
||||
dependent: {},
|
||||
objectArrays: {},
|
||||
|
@ -219,17 +219,31 @@ export function actionsAvailableWithAdditionalSubscription(
|
|||
currentSubscription
|
||||
) {
|
||||
switch (currentSubscription) {
|
||||
case "complete":
|
||||
return [];
|
||||
case "advanced":
|
||||
return action.actionTypesWithSubscription["business"];
|
||||
case "core":
|
||||
return action.actionTypesWithSubscription["advanced"].concat(
|
||||
action.actionTypesWithSubscription["business"]
|
||||
return [];
|
||||
case "basic":
|
||||
return action.actionTypesWithSubscription["advanced"];
|
||||
case "none", "":
|
||||
return action.actionTypesWithSubscription["basic"].concat(
|
||||
action.actionTypesWithSubscription["advanced"]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function actionsAvailableWithCurrentSubscription(
|
||||
currentSubscription
|
||||
) {
|
||||
switch (currentSubscription) {
|
||||
case "advanced":
|
||||
return action.actionTypesWithSubscription["advanced"].concat(
|
||||
action.actionTypesWithSubscription["basic"]);
|
||||
case "basic":
|
||||
return action.actionTypesWithSubscription["basic"];
|
||||
case "none", "":
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export function buildFieldTypes(types) {
|
||||
wizardSchema.field.types = types;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,12 @@
|
|||
<div class="texts">
|
||||
<span class="name">{{html-safe label}}</span>
|
||||
{{#if item.subscription}}
|
||||
<span class="subscription-label">{{i18n "admin.wizard.subscription.label"}}</span>
|
||||
<span class="subscription-label">
|
||||
{{#if item.disabled}}
|
||||
{{i18n "admin.wizard.subscription.additional_label"}}
|
||||
{{else}}
|
||||
{{i18n "admin.wizard.subscription.label"}}
|
||||
{{/if}}
|
||||
</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
|
|
@ -427,6 +427,10 @@
|
|||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.wizard-custom-action .select-kit-row.disabled {
|
||||
background: var(--primary-low);
|
||||
}
|
||||
|
||||
.select-box-kit-header {
|
||||
height: initial;
|
||||
}
|
||||
|
|
|
@ -467,6 +467,7 @@ en:
|
|||
subscription:
|
||||
nav_label: Subscription
|
||||
label: Subscription
|
||||
additional_label: "Add subscription"
|
||||
title: Custom Wizard Subscription
|
||||
authorize: Authorize
|
||||
authorized: Authorized
|
||||
|
|
|
@ -5,7 +5,7 @@ class CustomWizard::AdminController < ::Admin::AdminController
|
|||
def index
|
||||
render_json_dump(
|
||||
#TODO replace with appropriate static?
|
||||
api_section: ["complete"].include?(CustomWizard::Subscription.type),
|
||||
api_section: ["advanced"].include?(CustomWizard::Subscription.type),
|
||||
notices: ActiveModel::ArraySerializer.new(
|
||||
CustomWizard::Notice.list,
|
||||
each_serializer: CustomWizard::NoticeSerializer
|
||||
|
|
|
@ -13,7 +13,7 @@ class CustomWizard::Subscription::Subscription
|
|||
end
|
||||
|
||||
def types
|
||||
%w(core advanced complete)
|
||||
%w(none basic advanced)
|
||||
end
|
||||
|
||||
def active?
|
||||
|
|
Laden …
In neuem Issue referenzieren