diff --git a/assets/javascripts/discourse/components/wizard-links.js.es6 b/assets/javascripts/discourse/components/wizard-links.js.es6 index 62c45911..bf0dd242 100644 --- a/assets/javascripts/discourse/components/wizard-links.js.es6 +++ b/assets/javascripts/discourse/components/wizard-links.js.es6 @@ -78,16 +78,9 @@ export default Component.extend({ let params = setWizardDefaults({}, itemType); params.isNew = true; + params.index = items.length; - let index = 0; - if (items.length) { - let last_item = items[items.length - 1]; - index = Number(last_item.id.split("_").pop()); - } - - params.index = index; - - let id = `${itemType}_${index + 1}`; + let id = `${itemType}_${params.index + 1}`; if (itemType === "field") { id = `${this.parentId}_${id}`; } diff --git a/assets/javascripts/wizard/lib/initialize/patch-components.js.es6 b/assets/javascripts/wizard/lib/initialize/patch-components.js.es6 index d5e7ea25..9d13160e 100644 --- a/assets/javascripts/wizard/lib/initialize/patch-components.js.es6 +++ b/assets/javascripts/wizard/lib/initialize/patch-components.js.es6 @@ -64,13 +64,13 @@ export default { _wizardInsertText(args = {}) { if (args.fieldId === this.fieldId) { - this._insertText(args.text, args.options); + this.insertText(args.text, args.options); } }, _wizardReplaceText(args = {}) { if (args.fieldId === this.fieldId) { - this._replaceText(args.oldVal, args.newVal, (args.opts = {})); + this.replaceText(args.oldVal, args.newVal, (args.opts = {})); } }, @@ -89,7 +89,7 @@ export default { let html = clipboard.getData("text/html"); let handled = false; - const { pre, lineVal } = this._getSelected(null, { lineVal: true }); + const { pre, lineVal } = this.getSelected(null, { lineVal: true }); const isInlinePasting = pre.match(/[^\n]$/); const isCodeBlock = isInside(pre, /(^|\n)```/g); @@ -100,7 +100,7 @@ export default { !isCodeBlock ) { plainText = plainText.trim().replace(/\r/g, ""); - const table = this._extractTable(plainText); + const table = this.extractTable(plainText); if (table) { this.appEvents.trigger("wizard-editor:insert-text", { fieldId: this.fieldId, diff --git a/assets/stylesheets/admin/admin.scss b/assets/stylesheets/admin/admin.scss index f1911f2c..70d5d539 100644 --- a/assets/stylesheets/admin/admin.scss +++ b/assets/stylesheets/admin/admin.scss @@ -498,7 +498,6 @@ $error: #ef1700; } .d-editor-textarea-wrapper { - display: grid; margin-bottom: 10px; textarea { diff --git a/spec/components/custom_wizard/custom_field_spec.rb b/spec/components/custom_wizard/custom_field_spec.rb index e888634a..ff47585b 100644 --- a/spec/components/custom_wizard/custom_field_spec.rb +++ b/spec/components/custom_wizard/custom_field_spec.rb @@ -259,12 +259,12 @@ describe CustomWizard::CustomField do expect(CustomWizard::CustomField.list_by(:serializers, ['post']).length).to eq(0) end - it "custom field records added by other plugins " do - expect(CustomWizard::CustomField.external_list.length).to be > 10 + it "lists custom field records added by other plugins " do + expect(CustomWizard::CustomField.external_list.length).to eq(8) end - it "all custom field records" do - expect(CustomWizard::CustomField.full_list.length).to be > 12 + it "lists all custom field records" do + expect(CustomWizard::CustomField.full_list.length).to eq(12) end end diff --git a/spec/requests/custom_wizard/admin/custom_fields_controller_spec.rb b/spec/requests/custom_wizard/admin/custom_fields_controller_spec.rb index dea86c35..bc2dbb9d 100644 --- a/spec/requests/custom_wizard/admin/custom_fields_controller_spec.rb +++ b/spec/requests/custom_wizard/admin/custom_fields_controller_spec.rb @@ -13,7 +13,7 @@ describe CustomWizard::AdminCustomFieldsController do it "returns the full list of custom fields" do get "/admin/wizards/custom-fields.json" - expect(response.parsed_body["custom_fields"].length).to be > 12 + expect(response.parsed_body.length).to eq(12) end it "saves custom fields" do