Skip to content

Commit

Permalink
Merge pull request #8 from vokseverk/wip-v304
Browse files Browse the repository at this point in the history
Bugfix + feature update
  • Loading branch information
greystate authored May 26, 2023
2 parents fc6d6f2 + 4db6801 commit 4662700
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
Binary file modified images/keyvalue-config.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions src/keyvalueeditor.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,36 @@
$scope.addRemoveOnKeyDown = function (event, index) {
var KEY_ESCAPE = 13;
var KEY_BACKSPACE = 8;

var txtBoxValue = $scope.model.value[index];
var txtBoxKey = event.target.name === "item_" + index + "_key";
var txtBoxKey = event.target.name === ("item_" + index + "_key");

event.preventDefault();

switch (event.keyCode) {
case KEY_ESCAPE:
if ($scope.model.config.max <= 0 && txtBoxValue.value || $scope.model.value.length < $scope.model.config.max && txtBoxValue.value) {
var newItemIndex = index + 1;
$scope.model.value.splice(newItemIndex, 0, { key: "", value: "" });

// Set focus on the newly added value
$scope.model.value[newItemIndex].hasFocus = true;
}
break;

case KEY_BACKSPACE:
if ($scope.model.value.length > $scope.model.config.min) {
var remainder = [];

// Require an extra hit on backspace for the field to be removed
if (txtBoxValue.value === "" && txtBoxKey) {
if (txtBoxValue.key === "" && txtBoxKey) {
backspaceHits++;
} else {
backspaceHits = 0;
}

// Only a BACKSPACE in the empty "Key" field triggers remove
if (txtBoxKey && txtBoxValue.value === "" && backspaceHits === 2) {
if (txtBoxKey && txtBoxValue.key === "" && backspaceHits === 2) {
for (var x = 0; x < $scope.model.value.length; x++) {
if (x !== index) {
remainder.push($scope.model.value[x]);
Expand Down
4 changes: 2 additions & 2 deletions src/keyvalueeditor.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.vv-keyvalue-editor {

}

.vv-keyvalue-editor .flex-wrap.textbox-wrapper {
Expand All @@ -15,7 +15,7 @@

.vv-keyvalue-editor .vv-keyvalue-value {
margin-left: 10px;
flex: 1 1 50%;
flex: 1;
}

.vv-keyvalue-key::placeholder,
Expand Down
3 changes: 2 additions & 1 deletion src/keyvalueeditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
focus-when="{{item.hasFocus}}"
localize="placeholder"
placeholder="@keyvalue_keyPlaceholder"
style="flex-basis:{{model.config.split}}"
/>

<input type="text" name="item_{{$index}}_value"
Expand All @@ -19,7 +20,7 @@
placeholder="@keyvalue_valuePlaceholder"
/>
<i class="icon icon-navigation handle" localize="title" title="@general_move"></i>

<div class="umb-multiple-textbox__confirm" ng-show="model.value.length > model.config.min">
<button class="umb-multiple-textbox__confirm-action" type="button" prevet-default ng-click="showPrompt($index, item)" localize="title" title="@content_removeTextBox">
<i class="icon-trash"></i>
Expand Down
7 changes: 7 additions & 0 deletions src/manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@
<description>Enter the maximum number of key/value pairs</description>
<view>number</view>
</field>
<field>
<label>Key column split</label>
<key>split</key>
<description>Enter a CSS length value for the key column's width</description>
<view>textstring</view>
</field>
</prevalues>
<defaultConfig>
<min>0</min>
<max>5</max>
<split>140px</split>
</defaultConfig>
</propertyEditor>

Expand Down
2 changes: 1 addition & 1 deletion src/package.ent
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!ENTITY packageVersion "2.0.0">
<!ENTITY packageVersionV9 "2.0.0">
<!ENTITY packageVersionV10 "3.0.3">
<!ENTITY packageVersionV10 "3.0.4">
<!ENTITY packageVersionV11 "4.0.0">
<!ENTITY packageNamespace "Vokseverk">
<!ENTITY packageSafeName "KeyValueEditor">
Expand Down

0 comments on commit 4662700

Please sign in to comment.