From 211cf7840393b880c1c34f9816a608840d31a841 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Tue, 8 May 2018 08:03:41 -0400 Subject: [PATCH] Fix issue processwire/processwire-issues#586 unnecessary "clone_field" property in field settings after a field is cloned. Unrelated: this commit also converts InputfieldPageAutocomplete to use an scss file. --- .../InputfieldPageAutocomplete.css | 185 +++++++----------- .../InputfieldPageAutocomplete.scss | 129 ++++++++++++ .../Process/ProcessField/ProcessField.module | 4 +- 3 files changed, 206 insertions(+), 112 deletions(-) create mode 100644 wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.scss diff --git a/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.css b/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.css index 21274855..81f6c231 100644 --- a/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.css +++ b/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.css @@ -1,119 +1,84 @@ - .pw-content .InputfieldPageAutocomplete p { - margin: 0; -} - + margin: 0; } .pw-content .InputfieldPageAutocomplete ol { - margin: 0; - list-style: none; -} - - .pw-content .InputfieldPageAutocomplete ol li { - /* li item from the html list above */ - position: relative; - margin: 0 0 1px 0; - padding-left: 0; - list-style: none; - width: 100%; - line-height: 1em; - display: block; - cursor: move; - } - .InputfieldPageAutocomplete ol li i.fa-sort { - display: inline; - float: left; - margin-right: 7px; - position: relative; - top: 3px; - left: 3px; - opacity: 0.7; - } - .pw-content .InputfieldPageAutocomplete ol li:last-child { - margin-bottom: 0.5em; - } - - .InputfieldPageAutocomplete ol li .ui-icon-arrowthick-2-n-s { - float: left; - margin-top: 1px; - } - - .InputfieldPageAutocomplete ol li .itemLabel { - /* this is a span that surrounds the text in the item, except for the remove link */ - display: block; - padding: 3px 0 3px 5px; - cursor: move; - } - - .InputfieldPageAutocomplete ol li .itemRemove { - /* the remove link in each list item */ - position: absolute; - right: 3px; - top: 0; - } - .InputfieldPageAutocomplete ol li i.fa-trash { - position: relative; - top: 2px; - right: 3px; - } - - .InputfieldPageAutocomplete ol li .itemValue { - display: none; - } - - .InputfieldPageAutocomplete ol li.itemTemplate { - display: none !important; - } + margin: 0; + list-style: none; } + .pw-content .InputfieldPageAutocomplete ol li { + /* li item from the html list above */ + position: relative; + margin: 0 0 1px 0; + padding-left: 0; + list-style: none; + width: 100%; + line-height: 1em; + display: block; + cursor: move; } + .pw-content .InputfieldPageAutocomplete ol li i.fa-sort { + display: inline; + float: left; + margin-right: 7px; + position: relative; + top: 3px; + left: 3px; + opacity: 0.7; } + .pw-content .InputfieldPageAutocomplete ol li .ui-icon-arrowthick-2-n-s { + float: left; + margin-top: 1px; } + .pw-content .InputfieldPageAutocomplete ol li:last-child { + margin-bottom: 0.5em; } +.pw-content .InputfieldPageAutocomplete input.no_list { + /* some right padding for remove icon placement */ + padding-right: 22px; } +.InputfieldPageAutocomplete ol li .itemLabel { + /* this is a span that surrounds the text in the item, except for the remove link */ + display: block; + padding: 3px 0 3px 5px; + cursor: move; } +.InputfieldPageAutocomplete ol li .itemRemove { + /* the remove link in each list item */ + position: absolute; + right: 3px; + top: 0; } +.InputfieldPageAutocomplete ol li .itemValue { + display: none; } +.InputfieldPageAutocomplete ol li i.fa-trash { + position: relative; + top: 2px; + right: 3px; } +.InputfieldPageAutocomplete ol li.itemTemplate { + display: none !important; } .InputfieldPageAutocomplete input[type=text] { - /* some left padding for icon placement */ - width: 100%; - padding-left: 18px; -} - -.InputfieldPageAutocomplete input.no_list { - /* some right padding for remove icon placement */ - padding-right: 22px; -} - + /* some left padding for icon placement */ + width: 100%; + padding-left: 18px; } .InputfieldPageAutocomplete p { - position: relative; - margin-bottom: 0; -} - - .InputfieldPageAutocomplete p i.fa { - - /* icon placement */ - position: absolute; - top: 0.5em; - left: 1px; - opacity: 0.5; - } - .InputfieldPageAutocomplete p i.fa.InputfieldPageAutocompleteRemove { - /* remove icon, for no_list mode */ - left: auto; - right: 3px; - cursor: pointer; - } - .InputfieldPageAutocomplete p i.fa.InputfieldPageAutocompleteRemove:hover { - opacity: 1.0; - } + position: relative; + margin-bottom: 0; } + .InputfieldPageAutocomplete p i.fa { + /* icon placement */ + position: absolute; + top: 0.5em; + left: 1px; + opacity: 0.5; } + .InputfieldPageAutocomplete p i.fa.InputfieldPageAutocompleteRemove { + /* remove icon, for no_list mode */ + left: auto; + right: 3px; + cursor: pointer; } + .InputfieldPageAutocomplete p i.fa.InputfieldPageAutocompleteRemove:hover { + opacity: 1.0; } +.InputfieldPageAutocomplete .InputfieldPageAdd { + /* hide .InputfieldPageAdd since autocomplete uses it's own input for this */ + display: none; } .ui-autocomplete { - /* enforce scrolling, plus add a little shadow for better distinction from background */ - max-height: 230px; - overflow-y: auto; - overflow-x: hidden; - box-shadow: 0 1px 3px 3px rgba(0,0,0,0.3); -} - - -.InputfieldPageAutocomplete .InputfieldPageAdd { - /* hide .InputfieldPageAdd since autocomplete uses it's own input for this */ - display: none; -} + /* enforce scrolling, plus add a little shadow for better distinction from background */ + max-height: 230px; + overflow-y: auto; + overflow-x: hidden; + box-shadow: 0 1px 2px 2px rgba(0, 0, 0, 0.2); } .InputfieldPageAutocompleteNote { - /* Optional note with contextual helper tips */ - display: none; -} - + /* Optional note with contextual helper tips */ + display: none; } diff --git a/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.scss b/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.scss new file mode 100644 index 00000000..ef9a44a9 --- /dev/null +++ b/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.scss @@ -0,0 +1,129 @@ + +.pw-content .InputfieldPageAutocomplete { + p { + margin: 0; + } + ol { + margin: 0; + list-style: none; + + li { + /* li item from the html list above */ + position: relative; + margin: 0 0 1px 0; + padding-left: 0; + list-style: none; + width: 100%; + line-height: 1em; + display: block; + cursor: move; + + i.fa-sort { + display: inline; + float: left; + margin-right: 7px; + position: relative; + top: 3px; + left: 3px; + opacity: 0.7; + } + + .ui-icon-arrowthick-2-n-s { + float: left; + margin-top: 1px; + } + + } + li:last-child { + margin-bottom: 0.5em; + } + } + + input.no_list { + /* some right padding for remove icon placement */ + padding-right: 22px; + } + +} + +.InputfieldPageAutocomplete { + ol { + li { + .itemLabel { + /* this is a span that surrounds the text in the item, except for the remove link */ + display: block; + padding: 3px 0 3px 5px; + cursor: move; + } + + .itemRemove { + /* the remove link in each list item */ + position: absolute; + right: 3px; + top: 0; + } + + .itemValue { + display: none; + } + + i.fa-trash { + position: relative; + top: 2px; + right: 3px; + } + } + + li.itemTemplate { + display: none !important; + } + } + + input[type=text] { + /* some left padding for icon placement */ + width: 100%; + padding-left: 18px; + } + + p { + position: relative; + margin-bottom: 0; + + i.fa { + /* icon placement */ + position: absolute; + top: 0.5em; + left: 1px; + opacity: 0.5; + } + + i.fa.InputfieldPageAutocompleteRemove { + /* remove icon, for no_list mode */ + left: auto; + right: 3px; + cursor: pointer; + &:hover { + opacity: 1.0; + } + } + } + + .InputfieldPageAdd { + /* hide .InputfieldPageAdd since autocomplete uses it's own input for this */ + display: none; + } +} + +.ui-autocomplete { + /* enforce scrolling, plus add a little shadow for better distinction from background */ + max-height: 230px; + overflow-y: auto; + overflow-x: hidden; + box-shadow: 0 1px 2px 2px rgba(0,0,0,0.2); +} + +.InputfieldPageAutocompleteNote { + /* Optional note with contextual helper tips */ + display: none; +} + diff --git a/wire/modules/Process/ProcessField/ProcessField.module b/wire/modules/Process/ProcessField/ProcessField.module index 79c47536..aa4e4221 100644 --- a/wire/modules/Process/ProcessField/ProcessField.module +++ b/wire/modules/Process/ProcessField/ProcessField.module @@ -1362,7 +1362,7 @@ class ProcessField extends Process implements ConfigurableModule { /** @var InputfieldText $field */ $field = $this->modules->get("InputfieldText"); - $field->attr('id+name', 'clone_field'); + $field->attr('id+name', '_clone_field'); $field->attr('value', ''); $field->label = $this->_('Duplicate/clone this field?'); $field->icon = 'copy'; @@ -1643,7 +1643,7 @@ class ProcessField extends Process implements ConfigurableModule { $this->error($e->getMessage()); } - $cloneField = $this->form->get('clone_field'); + $cloneField = $this->form->get('_clone_field'); $cloneName = $cloneField ? $cloneField->attr('value') : ''; if($cloneName && $this->isAllowedName($cloneName)) { $clone = $this->fields->clone($this->field);