Skip to content

Commit e709990

Browse files
committed
ValueFieldSection moved to single file component
1 parent 0caa64c commit e709990

File tree

2 files changed

+45
-36
lines changed

2 files changed

+45
-36
lines changed

src/ValueFieldSection.vue

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<template>
2+
<span v-if="!enabled" @dblclick="toggleInput" class="editableField">{{this.entry[this.columnname]}}</span>
3+
<div v-else-if="enabled" class="input-group">
4+
<input type="text" class="form-control" v-model="datavalue" @keyup.enter="saveThis" @keyup.esc="cancelThis">
5+
<span class="input-group-btn">
6+
<button class="btn btn-danger" type="button" @click="cancelThis" ><span class="fa fa-times" aria-hidden="true"></span></button>
7+
<button class="btn btn-primary" type="button" @click="saveThis" ><span class="fa fa-check" aria-hidden="true"></span></button>
8+
</span>
9+
</div>
10+
</template>
11+
12+
<script>
13+
export default {
14+
name: "ValueFieldSection",
15+
props: ['entry','columnname'],
16+
data: function () {
17+
return {
18+
enabled: false,
19+
datavalue: "",
20+
}
21+
},
22+
methods: {
23+
saveThis: function () {
24+
var originalValue = this.entry[this.columnname];
25+
this.entry[this.columnname] = this.datavalue;
26+
this.$parent.$emit('cellDataModifiedEvent', originalValue, this.datavalue, this.columnname, this.entry);
27+
this.enabled = !this.enabled;
28+
},
29+
cancelThis: function () {
30+
this.datavalue = this.entry[this.columnname];
31+
this.enabled = !this.enabled;
32+
},
33+
toggleInput: function () {
34+
this.datavalue= this.entry[this.columnname];
35+
this.enabled=!this.enabled;
36+
},
37+
}
38+
}
39+
</script>
40+
41+
<style scoped>
42+
43+
</style>

src/VueBootstrapTable.vue

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -222,47 +222,13 @@
222222
import lodashorderby from 'lodash.orderby';
223223
import lodashincludes from 'lodash.includes';
224224
import lodashfindindex from 'lodash.findindex';
225+
import ValueFieldSection from "./ValueFieldSection.vue";
225226
226227
227-
/* Field Section used for displaying and editing value of cell */
228-
var valueFieldSection = {
229-
template: '<span v-if="!enabled" @dblclick="toggleInput" class="editableField">{{this.entry[this.columnname]}}</span>'+
230-
'<div v-else-if="enabled" class="input-group">'+
231-
' <input type="text" class="form-control" v-model="datavalue" @keyup.enter="saveThis" @keyup.esc="cancelThis">'+
232-
' <span class="input-group-btn">'+
233-
' <button class="btn btn-danger" type="button" @click="cancelThis" ><span class="fa fa-trash-alt" aria-hidden="true"></span></button>'+
234-
' <button class="btn btn-primary" type="button" @click="saveThis" ><span class="fa fa-check" aria-hidden="true"></span></button>'+
235-
' </span>'+
236-
'</div>',
237-
props: ['entry','columnname'],
238-
data: function () {
239-
return {
240-
enabled: false,
241-
datavalue: "",
242-
}
243-
},
244-
methods: {
245-
saveThis: function () {
246-
var originalValue = this.entry[this.columnname];
247-
this.entry[this.columnname] = this.datavalue;
248-
this.$parent.$emit('cellDataModifiedEvent', originalValue, this.datavalue, this.columnname, this.entry);
249-
this.enabled = !this.enabled;
250-
},
251-
cancelThis: function () {
252-
this.datavalue = this.entry[this.columnname];
253-
this.enabled = !this.enabled;
254-
},
255-
toggleInput: function () {
256-
this.datavalue= this.entry[this.columnname];
257-
this.enabled=!this.enabled;
258-
},
259-
}
260-
};
261-
262228
export default {
263229
name: "VueBootstrapTable",
264230
components: {
265-
'value-field-section': valueFieldSection,
231+
'value-field-section': ValueFieldSection,
266232
},
267233
props: {
268234
/**

0 commit comments

Comments
 (0)