Skip to content

Commit ad97f1c

Browse files
committed
ListInput shorter content to fit, fixed selector when container is not specified
1 parent 65dcf5b commit ad97f1c

File tree

1 file changed

+35
-24
lines changed

1 file changed

+35
-24
lines changed

public/js/vvvebjs/inputs.js

+35-24
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
/*
2-
Copyright 2017 Ziadin Givan
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
16-
https://github.com/givanz/VvvebJs
17-
*/
18-
1+
/**
2+
* Vvveb
3+
*
4+
* Copyright (C) 2021 Ziadin Givan
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*
19+
*/
20+
1921
let Input = {
2022

2123
init: function(name) {
@@ -734,7 +736,11 @@ let ListInput = { ...Input, ...{
734736
let data = input.data;
735737

736738
if (data.removeElement) {
737-
input.node.querySelector(data.container + " " + data.selector + ":nth-child(" + (index + 1) + ")").remove();
739+
let container = input.node;
740+
if (data.container) {
741+
container.querySelector(data.container);
742+
}
743+
container.querySelector(data.selector + ":nth-child(" + (index + 1) + ")").remove();
738744
}
739745
sectionItem.remove();
740746

@@ -748,7 +754,11 @@ let ListInput = { ...Input, ...{
748754
add: function(event, node, input) {
749755
let newElement = input.data.newElement ?? false;
750756
if (newElement) {
751-
event.data.input.node.querySelector(input.data.container).append(generateElements(newElement)[0]);
757+
let container = input.node;
758+
if (data.container) {
759+
container.querySelector(data.container);
760+
}
761+
container.append(generateElements(newElement)[0]);
752762
}
753763

754764
event.action = "add";
@@ -784,7 +794,7 @@ let ListInput = { ...Input, ...{
784794
if (data.nameElement) {
785795
element = element.querySelector(data.nameElement);
786796
}
787-
let name = (data.name = "text" ? element.textContent : element.id);
797+
let name = (data.name = "text" ? element.textContent.substr(0, 15) : element.id);
788798
options.push({
789799
name: name,
790800
type: (data.prefix ?? "") + (i + 1) + (data.suffix ?? ""),
@@ -806,9 +816,10 @@ let AutocompleteInput = { ...Input, ...{
806816
["autocomplete.change", "onAutocompleteChange", "input"],
807817
],
808818

809-
onAutocompleteChange: function(event, value, text) {
810-
input.value = value;
811-
return this.onChange(event, node);
819+
onAutocompleteChange: function(event, node, input) {
820+
input.value = event.detail.value;
821+
//return input.onChange(event, node, input);
822+
return input.onChange.call(this, event, node, input);
812823
},
813824

814825
init: function(data) {

0 commit comments

Comments
 (0)