Skip to content

Commit

Permalink
Fix saving navigation items for Craft Solo
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed May 7, 2022
1 parent 748ca92 commit a9827d1
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 63 deletions.
74 changes: 25 additions & 49 deletions config.codekit3
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"uuidString" : "ECE3F09A-2816-43C6-9715-3F4A30BD28C5"
}
],
"creatorBuild" : "34335",
"creatorBuild" : "34359",
"files" : {
"\/.github" : {
"ft" : 65536,
Expand Down Expand Up @@ -624,10 +624,6 @@
"active" : 0,
"optionString" : "'1tbs', {'allowSingleLine': true}"
},
"callback-return" : {
"active" : 0,
"optionString" : "['callback', 'cb', 'next']"
},
"camelcase" : {
"active" : 0,
"optionString" : "{'properties': 'always'}"
Expand Down Expand Up @@ -719,6 +715,10 @@
"active" : 0,
"optionString" : "'expression'"
},
"function-call-argument-newline" : {
"active" : 0,
"optionString" : "'always'"
},
"function-paren-newline" : {
"active" : 0,
"optionString" : "'multiline'"
Expand All @@ -731,21 +731,14 @@
"active" : 0,
"optionString" : "{'allowImplicit': false}"
},
"global-require" : {
"active" : 0
},
"grouped-accessor-pairs" : {
"active" : 0,
"optionString" : "'anyOrder'"
},
"guard-for-in" : {
"active" : 0
},
"handle-callback-err" : {
"active" : 0,
"optionString" : "'err'"
},
"id-blacklist" : {
"id-denylist" : {
"active" : 0,
"optionString" : "'data', 'err', 'e', 'cb', 'callback'"
},
Expand Down Expand Up @@ -869,9 +862,6 @@
"active" : 0,
"optionString" : "{'allow': ['~'], 'int32Hint': true}"
},
"no-buffer-constructor" : {
"active" : 0
},
"no-caller" : {
"active" : 0
},
Expand Down Expand Up @@ -899,6 +889,9 @@
"no-const-assign" : {
"active" : 1
},
"no-constant-binary-expression" : {
"active" : 0
},
"no-constant-condition" : {
"active" : 1,
"optionString" : "{'checkLoops': true}"
Expand Down Expand Up @@ -933,6 +926,9 @@
"no-dupe-keys" : {
"active" : 1
},
"no-duplicate-case" : {
"active" : 1
},
"no-duplicate-imports" : {
"active" : 0,
"optionString" : "{'includeExports': false}"
Expand Down Expand Up @@ -974,7 +970,7 @@
"no-extra-boolean-cast" : {
"active" : 1
},
"no-extra-labels" : {
"no-extra-label" : {
"active" : 0
},
"no-extra-parens" : {
Expand Down Expand Up @@ -1062,10 +1058,6 @@
"active" : 0,
"optionString" : "{'groups': [['+', '-', '*', '\/', '%', '**'], ['&', '|', '^', '~', '<<', '>>', '>>>'], ['==', '!=', '===', '!==', '>', '>=', '<', '<='], ['&&', '||'], ['in', 'instanceof']], 'allowSamePrecedence': true}"
},
"no-mixed-requires" : {
"active" : 0,
"optionString" : "{'grouping': false, 'allowCall': false }"
},
"no-mixed-spaces-and-tabs" : {
"active" : 0,
"optionString" : ""
Expand Down Expand Up @@ -1100,9 +1092,6 @@
"no-new-object" : {
"active" : 0
},
"no-new-require" : {
"active" : 0
},
"no-new-symbol" : {
"active" : 1
},
Expand All @@ -1125,19 +1114,10 @@
"active" : 0,
"optionString" : "{'props': false}"
},
"no-path-concat" : {
"active" : 0
},
"no-plusplus" : {
"active" : 0,
"optionString" : "{'allowForLoopAfterthoughts': false}"
},
"no-process-env" : {
"active" : 0
},
"no-process-exit" : {
"active" : 0
},
"no-promise-executor-return" : {
"active" : 0
},
Expand Down Expand Up @@ -1165,10 +1145,6 @@
"no-restricted-imports" : {
"active" : 0
},
"no-restricted-modules" : {
"active" : 0,
"optionString" : ""
},
"no-restricted-properties" : {
"active" : 0,
"optionString" : "[{'object': 'disallowedObjectName', 'property': 'disallowedPropertyName'}, {'object': 'disallowedObjectName', 'property': 'anotherDisallowedPropertyName', 'message': 'Please use allowedObjectName.allowedPropertyName.'}]"
Expand Down Expand Up @@ -1211,10 +1187,6 @@
"no-sparse-arrays" : {
"active" : 1
},
"no-sync" : {
"active" : 0,
"optionString" : ""
},
"no-tabs" : {
"active" : 0,
"optionString" : ""
Expand Down Expand Up @@ -1446,10 +1418,6 @@
"require-await" : {
"active" : 0
},
"require-jsdoc" : {
"active" : 0,
"optionString" : "{'require': {'FunctionDeclaration': true, 'MethodDefinition': false, 'ClassDeclaration': false, 'ArrowFunctionExpression': false}}"
},
"require-unicode-regexp" : {
"active" : 0
},
Expand Down Expand Up @@ -1535,10 +1503,6 @@
"active" : 1,
"optionString" : ""
},
"valid-jsdoc" : {
"active" : 0,
"optionString" : "{'prefer': {'return': 'returns'}, 'requireReturn': true, 'requireReturnDescription': true, 'requireReturnType': true, 'requireParamDescription': true}"
},
"valid-typeof" : {
"active" : 1,
"optionString" : "{'requireStringLiterals': true}"
Expand Down Expand Up @@ -2039,6 +2003,10 @@
"active" : 0,
"flagValue" : -1
},
"keep_numbers" : {
"active" : 0,
"flagValue" : -1
},
"keep_quoted_props" : {
"active" : 0,
"flagValue" : -1
Expand All @@ -2063,6 +2031,10 @@
"active" : 1,
"flagValue" : 1
},
"preserve_annotations" : {
"active" : 0,
"flagValue" : -1
},
"properties" : {
"active" : 1,
"flagValue" : -1
Expand Down Expand Up @@ -2167,6 +2139,10 @@
"active" : 0,
"flagValue" : -1
},
"wrap_func_args" : {
"active" : 1,
"flagValue" : -1
},
"wrap_iife" : {
"active" : 0,
"flagValue" : -1
Expand Down
10 changes: 5 additions & 5 deletions src/resources/dist/js/cp-nav-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ $(document).on('change', '.layout-select select', function() {

$(document).on('click', '.add-new-menu-item', function(e) {
var data = {
layoutId: $('.layout-select select').val(),
layoutId: $('[name="layoutId"]').val(),
type: $(this).data('type'),
};

Expand Down Expand Up @@ -475,7 +475,7 @@ $(document).on('change', '#cp-nav-items .lightswitch', function() {
var data = {
value: value,
id: row.data('id'),
layoutId: $('.layout-select select').val(),
layoutId: $('[name="layoutId"]').val(),
}

Craft.sendActionRequest('POST', 'cp-nav/navigation/toggle', { data })
Expand Down Expand Up @@ -526,7 +526,7 @@ Craft.CpNav.EditNavItem = Garnish.Base.extend({
this.data = {
id: $data.data('id'),
currLabel: $data.data('currlabel'),
layoutId: $('.layout-select select').val(),
layoutId: $('[name="layoutId"]').val(),
}

this.$spinner = $('<div class="spinner small" />');
Expand Down Expand Up @@ -629,7 +629,7 @@ $(document).on('click', 'tr.cp-nav-item a.delete', function(e) {

var data = {
id: $tr.data('id'),
layoutId: $('.layout-select select').val(),
layoutId: $('[name="layoutId"]').val(),
};

var confirmDeleteMessage = Craft.t('app', 'Are you sure you want to delete “{name}”?', { name: $tr.data('name') });
Expand Down Expand Up @@ -959,7 +959,7 @@ Craft.CpNav.NavAdminTable = Garnish.DragSort.extend({
// -----------------------------------------------------------------

var data = {
layoutId: $('.layout-select select').val(),
layoutId: $('[name="layoutId"]').val(),
items: [],
};

Expand Down
10 changes: 5 additions & 5 deletions src/resources/src/js/_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $(document).on('change', '.layout-select select', function() {

$(document).on('click', '.add-new-menu-item', function(e) {
var data = {
layoutId: $('.layout-select select').val(),
layoutId: $('[name="layoutId"]').val(),
type: $(this).data('type'),
};

Expand Down Expand Up @@ -207,7 +207,7 @@ $(document).on('change', '#cp-nav-items .lightswitch', function() {
var data = {
value: value,
id: row.data('id'),
layoutId: $('.layout-select select').val(),
layoutId: $('[name="layoutId"]').val(),
}

Craft.sendActionRequest('POST', 'cp-nav/navigation/toggle', { data })
Expand Down Expand Up @@ -258,7 +258,7 @@ Craft.CpNav.EditNavItem = Garnish.Base.extend({
this.data = {
id: $data.data('id'),
currLabel: $data.data('currlabel'),
layoutId: $('.layout-select select').val(),
layoutId: $('[name="layoutId"]').val(),
}

this.$spinner = $('<div class="spinner small" />');
Expand Down Expand Up @@ -361,7 +361,7 @@ $(document).on('click', 'tr.cp-nav-item a.delete', function(e) {

var data = {
id: $tr.data('id'),
layoutId: $('.layout-select select').val(),
layoutId: $('[name="layoutId"]').val(),
};

var confirmDeleteMessage = Craft.t('app', 'Are you sure you want to delete “{name}”?', { name: $tr.data('name') });
Expand Down Expand Up @@ -691,7 +691,7 @@ Craft.CpNav.NavAdminTable = Garnish.DragSort.extend({
// -----------------------------------------------------------------

var data = {
layoutId: $('.layout-select select').val(),
layoutId: $('[name="layoutId"]').val(),
items: [],
};

Expand Down
10 changes: 6 additions & 4 deletions src/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

{% set selectedTab = 'navigation' %}

{% set layoutItems = [] %}
{% set layoutOptions = [] %}
{% for layout in layouts %}
{% set layoutItems = layoutItems | merge([{ label: layout.name, value: layout.id }]) %}
{% set layoutOptions = layoutOptions | merge([{ label: layout.name, value: layout.id }]) %}
{% endfor %}

{% set layoutId = craft.app.request.param('layoutId') ?? '' %}
Expand Down Expand Up @@ -41,7 +41,9 @@
{{ 'CP Nav: Editing {name}' | t('cp-nav', { name: layout.name }) }}
</div>

{% if craft.app.getEditionName() != 'Solo' %}
{% if layouts | length == 1 %}
{{ hiddenInput('layoutId', layouts[0].id) }}
{% else %}
<div class="layout-select">
{{ forms.selectField({
first: true,
Expand All @@ -50,7 +52,7 @@
id: 'layoutId',
name: 'layoutId',
value: layoutId,
options: layoutItems,
options: layoutOptions,
}) }}
</div>
{% endif %}
Expand Down

0 comments on commit a9827d1

Please sign in to comment.