1
0
Fork 0

Namespace CSS and remove uneccessary site attributes

Dieser Commit ist enthalten in:
Angus McLeod 2022-07-27 14:40:05 +01:00
Ursprung 60823cd87a
Commit 150afb29e0
22 geänderte Dateien mit 1335 neuen und 1504 gelöschten Zeilen

Datei anzeigen

@ -3,7 +3,7 @@ class CustomWizard::WizardController < ::ApplicationController
before_action :ensure_plugin_enabled
before_action :ensure_logged_in, only: [:skip]
def index
def show
if wizard.present?
render json: CustomWizard::WizardSerializer.new(wizard, scope: guardian, root: false).as_json, status: 200
else
@ -31,26 +31,8 @@ class CustomWizard::WizardController < ::ApplicationController
render json: result
end
def qunit
raise Discourse::InvalidAccess.new if Rails.env.production?
respond_to do |format|
format.html do
render "default/empty"
end
end
end
protected
def ensure_logged_in
raise Discourse::NotLoggedIn.new unless current_user.present?
end
def guardian
@guardian ||= Guardian.new(current_user, request)
end
def wizard
@wizard ||= begin
builder = CustomWizard::Builder.new(params[:wizard_id].underscore, current_user)
@ -61,41 +43,6 @@ class CustomWizard::WizardController < ::ApplicationController
end
end
def wizard_page_title
wizard ? (wizard.name || wizard.id) : I18n.t('wizard.custom_title')
end
def wizard_theme_id
wizard ? wizard.theme_id : nil
end
def wizard_theme_lookup(name)
Theme.lookup_field(wizard_theme_id, view_context.mobile_view? ? :mobile : :desktop, name)
end
def wizard_theme_translations_lookup
Theme.lookup_field(wizard_theme_id, :translations, I18n.locale)
end
def preload_wizard_json
return if request.xhr? || request.format.json?
return if request.method != "GET"
store_preloaded("siteSettings", SiteSetting.client_settings_json)
end
def store_preloaded(key, json)
@preloaded ||= {}
@preloaded[key] = json.gsub("</", "<\\/")
end
## Simplified version of with_resolved_locale in ApplicationController
def with_resolved_locale
locale = current_user ? current_user.effective_locale : SiteSetting.default_locale
I18n.ensure_all_loaded!
I18n.with_locale(locale) { yield }
end
private
def ensure_plugin_enabled

Datei anzeigen

@ -9,13 +9,10 @@ class CustomWizard::WizardSerializer < CustomWizard::BasicWizardSerializer
:completed,
:required,
:permitted,
:uncategorized_category_id,
:categories,
:resume_on_revisit
has_many :steps, serializer: ::CustomWizard::StepSerializer, embed: :objects
has_one :user, serializer: ::BasicUserSerializer, embed: :objects
has_many :groups, serializer: ::BasicGroupSerializer, embed: :objects
def completed
object.completed?
@ -46,24 +43,4 @@ class CustomWizard::WizardSerializer < CustomWizard::BasicWizardSerializer
def include_steps?
!include_completed?
end
def include_categories?
object.needs_categories
end
def include_groups?
object.needs_groups
end
def uncategorized_category_id
SiteSetting.uncategorized_category_id
end
def include_uncategorized_category_id?
object.needs_categories
end
def categories
object.categories.map { |c| c.to_h }
end
end

Datei anzeigen

@ -1,62 +0,0 @@
<html>
<head>
<%= discourse_color_scheme_stylesheets %>
<%= discourse_stylesheet_link_tag :wizard, theme_id: nil %>
<%= discourse_stylesheet_link_tag :wizard_custom %>
<%- if wizard_theme_id.present? %>
<%= discourse_stylesheet_link_tag (mobile_view? ? :mobile_theme : :desktop_theme), theme_id: wizard_theme_id %>
<%- end %>
<%= preload_script "locales/#{I18n.locale}" %>
<%= preload_script "ember_jquery" %>
<%= preload_script "wizard-vendor" %>
<%= preload_script "wizard-custom" %>
<%= preload_script "wizard-raw-templates" %>
<%= preload_script "wizard-plugin" %>
<%= preload_script "pretty-text-bundle" %>
<%= preload_script_url ExtraLocalesController.url("wizard") %>
<%= csrf_meta_tags %>
<%- unless customization_disabled? %>
<%= wizard_theme_translations_lookup %>
<%= raw wizard_theme_lookup("head_tag") %>
<%- end %>
<%= server_plugin_outlet "custom_wizard" %>
<%= tag.meta id: 'data-discourse-setup', data: client_side_setup_data %>
<meta name="discourse_theme_id" content="<%= wizard_theme_id %>">
<meta name="discourse-base-uri" content="<%= Discourse.base_path %>">
<%= render partial: "layouts/head" %>
<title><%= wizard_page_title %></title>
</head>
<body class='custom-wizard wizard'>
<%- unless customization_disabled? %>
<%= raw wizard_theme_lookup("header") %>
<%- end %>
<div id='custom-wizard-main'></div>
<%- unless customization_disabled? %>
<%= raw wizard_theme_lookup("body_tag") %>
<%- end %>
<%- if current_user %>
<%= preload_script 'wizard-custom-start' %>
<%- else %>
<%= preload_script 'wizard-custom-guest' %>
<%- end %>
<div id="svg-sprites" style="display:none;">
<div class="fontawesome">
<%= raw SvgSprite.bundle %>
</div>
</div>
<div class="hidden" id="data-preloaded-wizard" data-preloaded-wizard="<%= preloaded_json %>"></div>
</body>
</html>

Datei anzeigen

@ -34,7 +34,7 @@ export default ComposerEditor.extend({
if (this.siteSettings.enable_mentions) {
$input.autocomplete({
template: findRawTemplate("user-selector-autocomplete"),
dataSource: (term) => this.userSearchTerm.call(this, term),
dataSource: (term) => this._userSearchTerm.call(this, term),
key: "@",
transformComplete: (v) => v.username || v.name,
afterComplete: (value) => {

Datei anzeigen

@ -1,8 +1,13 @@
import { findCustomWizard, updateCachedWizard } from "../models/custom-wizard";
import I18n from "I18n";
import Route from "@ember/routing/route";
import DiscourseRoute from "discourse/routes/discourse";
export default DiscourseRoute.extend({
titleToken() {
const wizard = this.modelFor('custom-wizard');
return wizard ? (wizard.name || wizard.id) : I18n.t('wizard.custom_title');
},
export default Route.extend({
beforeModel(transition) {
if (transition.intent.queryParams) {
this.set("queryParams", transition.intent.queryParams);

Datei anzeigen

@ -4,4 +4,3 @@
maximum=field.limit
onChange=(action (mut categories))
tabindex=field.tabindex}}

Datei anzeigen

@ -1,5 +1,5 @@
{{custom-wizard-group-selector
groups=wizard.groups
groups=site.groups
field=field
whitelist=field.content
value=field.value

Datei anzeigen

@ -1,8 +1,4 @@
img.avatar {
border-radius: 50%;
vertical-align: middle;
}
body.custom-wizard {
div.ac-wrap {
box-sizing: border-box;
position: relative;
@ -173,3 +169,4 @@ div.ac-wrap {
margin-right: 5px;
}
}
}

Datei anzeigen

@ -1,3 +1,4 @@
body.custom-wizard {
.badge-wrapper {
font-size: $font-down-1;
font-weight: bold;
@ -128,3 +129,4 @@
margin-right: 5px;
}
}
}

Datei anzeigen

@ -1,3 +1,4 @@
body.custom-wizard {
input {
display: inline-block;
padding: 4px 10px;
@ -28,6 +29,7 @@ select,
textarea {
color: var(--primary);
caret-color: currentColor;
width: 100%;
&[class*="span"] {
float: none;
@ -57,34 +59,7 @@ textarea {
}
}
.spinner {
margin: 20px auto 20px auto;
position: relative;
-webkit-animation: rotate-forever 1s infinite linear;
animation: rotate-forever 1s infinite linear;
height: 30px;
width: 30px;
border: 4px solid var(--primary-low-mid);
border-right-color: transparent;
border-radius: 50%;
&.small {
width: 10px;
height: 10px;
margin: 0;
display: inline-block;
}
}
@keyframes rotate-forever {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.body-length {
text-align: right;
}
}

Datei anzeigen

@ -1,3 +1,4 @@
body.custom-wizard {
.wizard-btn {
border-radius: 2px;
font-size: var(--font-0);
@ -86,3 +87,4 @@
color: var(--tertiary-hover);
}
}
}

Datei anzeigen

@ -1,3 +1,4 @@
body.custom-wizard {
.d-editor-container {
display: flex;
flex-grow: 1;
@ -278,3 +279,4 @@
}
}
}
}

Datei anzeigen

@ -1,5 +1,4 @@
// event form
body.custom-wizard {
.event-form {
width: 585px;
max-width: 80vw;
@ -512,3 +511,4 @@ li.ui-timepicker-selected .ui-timepicker-duration,
.ui-timepicker-list li.ui-timepicker-selected.ui-timepicker-disabled {
background: #f2f2f2;
}
}

Datei anzeigen

@ -0,0 +1,5 @@
body.custom-wizard {
.d-header .panel {
display: none;
}
}

Datei anzeigen

@ -1,3 +1,4 @@
body.custom-wizard {
.location-form-instructions {
color: #919191;
margin: 5px 0;
@ -189,3 +190,4 @@ div.input-location {
color: #919191;
}
}
}

Datei anzeigen

@ -1,3 +1,4 @@
body.custom-wizard {
span.mentionable-item {
font-weight: bold;
}
@ -30,3 +31,4 @@ a.mentionable-item span {
object-fit: contain;
}
}
}

Datei anzeigen

@ -1,3 +1,4 @@
body.custom-wizard {
.similar-topics-validator {
position: relative;
display: flex;
@ -38,3 +39,4 @@
cursor: pointer;
}
}
}

Datei anzeigen

@ -16,7 +16,7 @@ body.custom-wizard {
width: 100%;
border: 1px solid var(--primary-low-mid);
border-radius: 5px;
margin: 0 auto;
margin: 0 auto 2.5em auto;
.wizard-field .input-area {
margin: 0.5em 0;
@ -144,13 +144,13 @@ body.custom-wizard {
.wizard-column .action-link {
color: var(--tertiary);
}
}
.no-access-gutter {
margin-top: 10px;
display: flex;
justify-content: flex-end;
}
}
/* IE11 hacks */

Datei anzeigen

@ -1,5 +1,6 @@
@import "custom/base";
@import "custom/wizard";
@import "custom/header";
@import "custom/step";
@import "custom/badges";
@import "custom/buttons";

Datei anzeigen

@ -1,10 +1,9 @@
# frozen_string_literal: true
CustomWizard::Engine.routes.draw do
get 'qunit' => 'wizard#qunit'
get ':wizard_id' => 'wizard#index'
get ':wizard_id' => 'wizard#show'
put ':wizard_id/skip' => 'wizard#skip'
get ':wizard_id/steps' => 'wizard#index'
get ':wizard_id/steps/:step_id' => 'wizard#index'
get ':wizard_id/steps' => 'wizard#show'
get ':wizard_id/steps/:step_id' => 'wizard#show'
put ':wizard_id/steps/:step_id' => 'steps#update'
end

Datei anzeigen

@ -120,18 +120,6 @@ class CustomWizard::Builder
params[:property] = field_template['property']
end
if field_template['type'] === 'category' || (
field_template['validations'] &&
field_template['validations']['similar_topics'] &&
field_template['validations']['similar_topics']['categories'].present?
)
@wizard.needs_categories = true
end
if field_template['type'] === 'group'
@wizard.needs_groups = true
end
if (content_inputs = field_template['content']).present?
content = CustomWizard::Mapper.new(
inputs: content_inputs,

Datei anzeigen

@ -23,8 +23,6 @@ class CustomWizard::Wizard
:restart_on_revisit,
:resume_on_revisit,
:permitted,
:needs_categories,
:needs_groups,
:steps,
:step_ids,
:field_ids,
@ -54,8 +52,6 @@ class CustomWizard::Wizard
@after_time_scheduled = attrs['after_time_scheduled']
@required = cast_bool(attrs['required'])
@permitted = attrs['permitted'] || nil
@needs_categories = false
@needs_groups = false
@theme_id = attrs['theme_id']
if attrs['theme'].present?
@ -243,14 +239,6 @@ class CustomWizard::Wizard
)
end
def categories
@categories ||= ::Site.new(Guardian.new(user)).categories
end
def groups
@groups ||= ::Site.new(Guardian.new(user)).groups
end
def update_step_ids
@step_ids = steps.map(&:id)
end