diff --git a/app/assets/javascripts/admin/addon/components/admin-badges-show.gjs b/app/assets/javascripts/admin/addon/components/admin-badges-show.gjs index 1936cd7a59ec6..29d01ca6ea527 100644 --- a/app/assets/javascripts/admin/addon/components/admin-badges-show.gjs +++ b/app/assets/javascripts/admin/addon/components/admin-badges-show.gjs @@ -210,6 +210,11 @@ export default class AdminBadgesShow extends Component { this.formApi = api; } + @action + toggleBadgeEnabled(value, { set }) { + set("enabled", value); + } + @action async handleDelete() { if (!this.args.badge?.id) { @@ -244,23 +249,14 @@ export default class AdminBadgesShow extends Component { class="badge-form current-badge content-body" as |form data| > - -

- {{iconOrImage data}} - {{data.name}} -

- - - - + + + {{data.name}} + + + This is a subtitle + + {{#if this.readOnly}} @@ -270,6 +266,7 @@ export default class AdminBadgesShow extends Component { {{icon "pencil"}} @@ -280,29 +277,25 @@ export default class AdminBadgesShow extends Component { @name="name" @disabled={{this.readOnly}} @validation="required" + @description="This is a required field" + @helpText="This is a required field" as |field| > {{/if}} - - - - {{#each this.badgeTypes as |badgeType|}} - - {{badgeType.name}} - - {{/each}} - - + + + + + + + {{#each this.badgeTypes as |badgeType|}} + + {{badgeType.name}} + + {{/each}} + + {{#if this.readOnly}} {{icon "pencil"}} @@ -384,6 +395,7 @@ export default class AdminBadgesShow extends Component { @query={{hash q=(concat this.textCustomizationPrefix "long_description") }} + class="btn-flat" > {{icon "pencil"}} @@ -493,7 +505,6 @@ export default class AdminBadgesShow extends Component { @title={{i18n "admin.badges.allow_title"}} @showTitle={{false}} @name="allow_title" - @format="full" as |field| > @@ -504,7 +515,6 @@ export default class AdminBadgesShow extends Component { @showTitle={{false}} @name="multiple_grant" @disabled={{this.readOnly}} - @format="full" as |field| > @@ -520,7 +530,6 @@ export default class AdminBadgesShow extends Component { @showTitle={{false}} @name="listable" @disabled={{this.readOnly}} - @format="full" as |field| > @@ -531,7 +540,6 @@ export default class AdminBadgesShow extends Component { @showTitle={{false}} @name="show_posts" @disabled={{this.readOnly}} - @format="full" as |field| > @@ -542,7 +550,6 @@ export default class AdminBadgesShow extends Component { @showTitle={{false}} @name="show_in_post_header" @disabled={{this.disableBadgeOnPosts data}} - @format="full" as |field| > diff --git a/app/assets/javascripts/admin/addon/components/form-kit-site-setting-wrapper.gjs b/app/assets/javascripts/admin/addon/components/form-kit-site-setting-wrapper.gjs new file mode 100644 index 0000000000000..1ce4cda3e44ca --- /dev/null +++ b/app/assets/javascripts/admin/addon/components/form-kit-site-setting-wrapper.gjs @@ -0,0 +1,333 @@ +import Component from "@glimmer/component"; +import { cached } from "@glimmer/tracking"; +import { concat, fn, hash } from "@ember/helper"; +import { action } from "@ember/object"; +import { service } from "@ember/service"; +import { htmlSafe } from "@ember/template"; +import { eq, not } from "truth-helpers"; +import DButton from "discourse/components/d-button"; +import Form from "discourse/components/form"; +import { humanizedSettingName } from "discourse/lib/site-settings-utils"; +import FontList from "admin/components/site-settings/font-list"; +import GroupList from "admin/components/site-settings/group-list"; +import HostList from "admin/components/site-settings/host-list"; +import ValueList from "admin/components/value-list"; +import SiteSetting from "admin/models/site-setting"; +import CategoryChooser from "select-kit/components/category-chooser"; + +class PrimaryActions extends Component { + @service toasts; + @service router; + + get cannotRevert() { + return this.args.field.value === this.args.setting.default; + } + + @action + async revertToDefault(menu) { + await menu.close(); + + this.args.field.set(this.args.setting.default); + this.args.save({ + [this.args.setting.setting]: this.args.field.value, + }); + } + + @action + settingHistory() { + this.router.transitionTo("adminLogs.staffActionLogs", { + queryParams: { + filters: { + subject: this.args.setting.setting, + action_name: "change_site_setting", + }, + force_refresh: true, + }, + }); + } + + @action + async copyStettingAsUrl(menu) { + await menu.close(); + + const url = `${window.location.origin}/admin/site_settings/category/all_results?filter=${this.args.setting.setting}`; + navigator.clipboard.writeText(url).then(() => { + this.toasts.success({ data: { message: "Copied to clipboard!" } }); + }); + } + + +} + +export default class FormKitSiteSettingWrapper extends Component { + @action + settingTitle(setting) { + return humanizedSettingName(setting.setting, setting.label); + } + + @cached + get formData() { + const data = {}; + this.args.settings.forEach((setting) => { + data[setting.setting] = setting.value; + }); + return data; + } + + async save(data, fields) { + const params = {}; + Object.keys(data).forEach((key) => { + const value = data[key]; + // this.args.setting.buffered.set( + // this.args.setting.setting, + // data[this.args.setting.setting] + // ); + // this.args.setting.buffered.applyChanges(); + params[key] = { + value, + backfill: false, + }; + }); + await SiteSetting.bulkUpdate(params); + } + + @action + fieldFormat(settingType) { + switch (settingType) { + case "integer": + case "float": + return "medium"; + default: + return "full"; + } + } + + @action + setValueList(set, delimiter, value) { + set(value.join(delimiter)); + } + + @action + setCategory(set, category) { + set(category?.id); + } + + +} diff --git a/app/assets/javascripts/admin/addon/components/site-settings/category.gjs b/app/assets/javascripts/admin/addon/components/site-settings/category.gjs index 765911e0525ba..402dc93b20227 100644 --- a/app/assets/javascripts/admin/addon/components/site-settings/category.gjs +++ b/app/assets/javascripts/admin/addon/components/site-settings/category.gjs @@ -5,7 +5,7 @@ import CategoryChooser from "select-kit/components/category-chooser"; const Category = ; diff --git a/app/assets/javascripts/admin/addon/components/site-settings/group-list.gjs b/app/assets/javascripts/admin/addon/components/site-settings/group-list.gjs index 8901a329cc01d..b8fc57a6a1339 100644 --- a/app/assets/javascripts/admin/addon/components/site-settings/group-list.gjs +++ b/app/assets/javascripts/admin/addon/components/site-settings/group-list.gjs @@ -21,7 +21,11 @@ export default class GroupList extends Component { @action onChangeGroupListSetting(value) { - this.set("value", value.join(this.tokenSeparator)); + if (this.onChange) { + this.onChange(value.join(this.tokenSeparator)); + } else { + this.set("value", value.join(this.tokenSeparator)); + } }