Skip to content

Commit

Permalink
v1.2.2
Browse files Browse the repository at this point in the history
- sort items b4 rendering
- remove array conversion on save as it was causing issues
- automatically lowerCase the keys, and replace spaces with underscore
- allow newline in value
- fix item losing focus because of tippy
  • Loading branch information
ctf0 committed Nov 13, 2017
1 parent 937e761 commit baa62b2
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 23 deletions.
2 changes: 0 additions & 2 deletions logs/v1.2.1.txt

This file was deleted.

5 changes: 5 additions & 0 deletions logs/v1.2.2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- sort items b4 rendering
- remove array conversion on save as it was causing issues
- automatically lowerCase the keys, and replace spaces with underscore
- allow newline in value
- fix item losing focus because of tippy
3 changes: 3 additions & 0 deletions src/Controllers/LingoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ public function getFileData(Request $request)
}
}

// sort keys
ksort($res);

return $this->goodResponse([
'locales'=> $locales,
'all' => $res,
Expand Down
5 changes: 0 additions & 5 deletions src/Controllers/Ops.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ protected function saveToFile($file, $data, $package_name = null)
$dir = "$dir_name/$locale";
$str = "<?php\n\nreturn " . var_export($value, true) . ';';

// array(...) to [...]
$str = str_replace('array (', '[', $str);
$str = str_replace(')', ']', $str);
$str = preg_replace('/=>\s+\[/', '=> [', $str);

if (!$this->file->put("$dir/$file", $str)) {
return false;
}
Expand Down
7 changes: 6 additions & 1 deletion src/resources/assets/js/Tabs/ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export default {
newKeys: '',
dataChanged: false,
newItemCounter: 0,
keyToCopy : ''
keyToCopy : '',
currentInputRef: ''
}
},
mounted() {
Expand Down Expand Up @@ -64,6 +65,7 @@ export default {
// copy to clipboard
$(document).on('click', '.c2c', () => {
this.$copyText(this.keyToCopy)
this.refocus()
})
},
activated() {
Expand Down Expand Up @@ -132,6 +134,9 @@ export default {
: `'${str}'`

return rep
},
refocus() {
return this.currentInputRef.target.focus()
}
},
watch: {
Expand Down
43 changes: 28 additions & 15 deletions src/resources/assets/js/Tabs/shared/content.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<div class="level is-mobile">
<div class="level is-mobile is-marginless">
<!-- items count -->
<div class="level-left">
<div class="level-item">
Expand Down Expand Up @@ -59,27 +59,30 @@
<tr v-for="(mainV, mainK, mainI) in selectedFileDataClone" :key="mainI">
<td nowrap contenteditable dir="auto"
:title="getKey(mainK)"
v-tippy="{ position : 'right', arrow: true, interactive: true}"
v-tippy="{ position : 'right', arrow: true, interactive: true, trigger: 'mouseenter'}"
@shown="refocus()"
data-html="#tippyTemplate"
@mouseover="keyToCopy = getKey(mainK)"
@mouseenter="keyToCopy = getKey(mainK)"

:class="nestCheck(mainK)"
:data-main-key="mainK"
v-html="mainK"
@keydown.enter.prevent
@input="newEntry()"
@focus="getPos($event)"
@blur="saveNewKey($event)">
{{ mainK }}
</td>

<td v-for="(nestV, nestK, nestI) in mainV" :key="nestI"
contenteditable dir="auto"
:data-main-key="mainK"
:data-code="nestK"
v-html="nestV"
@keydown.enter.prevent
@input="newEntry()"
@focus="getPos($event)"
@blur="saveNewValue($event)">
{{ nestV }}
</td>

<td width="1%">
<button class="button is-danger" @click="removeItem(mainK)">
<span class="icon">
Expand Down Expand Up @@ -107,6 +110,7 @@
</button>
</div>
</div>

<div class="level-left">
<div class="level-item">
<button class="button is-success" :disabled="!dataChanged" @click="submitNewData()">
Expand Down Expand Up @@ -135,8 +139,7 @@
}
#tippyTemplate {
height: 1px;
visibility: hidden;
display: none;
}
.c2c {
Expand Down Expand Up @@ -255,6 +258,8 @@ export default{
this.parentMethod('resetAll', ['selectedFile'])
}
this.parentMethod('resetAll', ['keyToCopy', 'currentInputRef'])
},
// util
Expand All @@ -263,9 +268,9 @@ export default{
this.parentMethod('reflowTable')
},
saveNewKey(e) {
this.parentMethod('reflowTable')
let old_key = e.target.dataset.mainKey
let new_key = e.target.innerText
let text = e.target.innerText = e.target.innerText.toLowerCase().replace(/\s/g, '_')
let new_key = text
if (old_key !== new_key) {
this.dataChanged = true
Expand All @@ -278,10 +283,10 @@ export default{
}
},
saveNewValue(e) {
this.parentMethod('reflowTable')
let code = e.target.dataset.code
let key = e.target.dataset.mainKey
let value = e.target.innerText
let text = e.target.innerText = e.target.innerText.replace(/\n/g, '<br>')
let value = text
if (this.selectedFileDataClone[key][code] !== value) {
this.dataChanged = true
Expand Down Expand Up @@ -315,6 +320,17 @@ export default{
return main
},
// tippy & ctcp
getPos(e) {
this.currentInputRef = e
},
refocus() {
return this.parentMethod('refocus')
},
getKey(key) {
return this.parentMethod('getKey', key)
},
// other
nestCheck(item) {
return item.includes('.') ? 'nestedKey' : ''
Expand All @@ -325,9 +341,6 @@ export default{
trans(key) {
return this.parentMethod('trans', key)
},
getKey(key) {
return this.parentMethod('getKey', key)
},
parentMethod(method_name, args = null) {
return this.$parent[method_name](args)
}
Expand Down

0 comments on commit baa62b2

Please sign in to comment.