├── .gitignore
├── .travis.yml
├── LICENSE
├── LICENSE_HEADER.txt
├── README.md
├── example
├── app.js
├── example.gif
└── index.html
├── gulpfile.js
└── src
├── vue-editable.css
└── vue-editable.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - '7'
4 | before_install:
5 | - npm install gulp
6 | - npm install gulp-uglify gulp-util gulp-concat gulp-minify-css gulp-header
7 | script:
8 | - gulp build
9 | - zip -rj build_travis.zip dist/**
10 | deploy:
11 | skip_cleanup: true
12 | provider: releases
13 | api_key:
14 | secure: yB2Xax+N/reGRjuiiQCnucDPqB6+iT1pnK3YH+976xpclmF7Hd0PXop8GvxyV3sX7ijs/ZDSTi3C8OxLGbW5b1wKbxfmP/UNeuJX2lVtYJwh2yQgByLnsKaP+QhC5GgFUW8eqU1+F1SjGUJsa9BspcQru70WaErW8c6EOLO+zET3O45O+XSyiSwbRMKAVr2YjN6EHEK5QxhHMCmzceDjO26RQn6bL3kD9RomjoIITFri7vtByh8iqwPk4XXFs8Qe7NArA3dra58NistImBJGQuuOLx+e1WbZs8KdMOyvKokyoCoJxobCKj7Oun7+Et9Yx6i7fFpw4pl1GKXN6OzCmFHEVRpnsn9cH4CUxjYFEceTlL6S5JDs8IAla5KU0pLdNIl0itjsJu8OgXCxdmCaaXoNnFhx31rbtAl6rybYfNaRDTf8i9cwKM3tVIOcZGu+/XHslWwHWp7sOiQ4n2tulBTcFx0WiHp4U8urEXktqM7Oijgfwlu/VAex1c+YTegSSUOFEFYkMjuvl20PHPm+N8coIsq2Ki/Pmvyoxeyr5kSkNsni2wyv312hkDqWXKPImL6Y+QPxGvMmFFfgUWYjRW2vRTDa1RCiFTt6lcfur3pjNerkaBEMxW1XKpa4kvtWNdJRLKbxU4ABzQ69AvV3bQwRE8M2/gY+L6CX+0uWY4k=
15 | file_glob: true
16 | file: build_travis.zip
17 | on:
18 | tags: true
19 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Christoph Müller
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/LICENSE_HEADER.txt:
--------------------------------------------------------------------------------
1 | /**
2 | MIT License
3 |
4 | Copyright (c) 2017 Christoph Müller
5 | **/
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-editable
2 |
3 | [](https://vuejs.org)
4 | [](https://travis-ci.org/cmllr/vue-editable)
5 |
6 |
7 | 
8 |
9 | In-place editing for Vue.js 2.
10 |
11 | > This plugin is still under active development. Do not use in production projects.
12 |
13 | ## Bootstrap
14 |
15 | 1. Include `vue-editable.min.js` and `vue-editable.min.css` from https://github.com/cmllr/vue-editable/releases
16 | 2. Include the plugin via `Vue.use(editable)`
17 |
18 | ## Core features
19 |
20 | The directive `v-editable=dataMember` is the main directive. The attribute value is a existing property. If `dataMember` is a nested structure, simply use a `foo.bar.barz`-like syntax.
21 |
22 | ```
23 |
24 | ```
25 |
26 | ### Danger ahead: Iterated edit
27 |
28 | If you want to edit objects out of an loop, e. g. `v-for`, you have to inform the library what the given index of the object is.
29 |
30 | For this purpose, you can use the `data-index` attribute. Note the `:` just before the attribute's name!
31 |
32 | ```
33 | :data-index="key"
34 | ```
35 |
36 | If your array does contain objects, not scalar types (like number or string), you also have to attribute the property which should be edited. For this purpose, you can use the attribute `data-property=name`. Please note: There is no `:` before the attribute name.
37 |
38 | ```
39 | data-property="customerName"
40 | ```
41 |
42 | ## Attributes
43 |
44 | If you want to control the display of the displayed input, e. g. with `input type='number'`, you can do this with the suffix `data-`. E. g. `type` becomes `data-type`, the content remains the same.
45 |
46 | ## Events
47 |
48 | ```
49 | vm.$on(name,function(e){
50 | //do something
51 | });
52 |
53 | ```
54 |
55 | |Event-Name|e|
56 | |-|-|
57 | |editable-changed|An object with members `newValue` and `oldValue` (dereferenced)|
58 | |editable-opened|the element which is currently edited|
59 | |editable-aborted|the element which should be edited|
60 |
61 | ## Type keeping
62 |
63 | The library tries to guess the old value type and converts the new value according to the determined type. There is currently not settings for turning this on or off or in case of switching types, e. g. form `int` to `float`.
64 |
65 | ## Problems
66 |
67 | - `v-for` expression do not work overall
68 | - not pretty at all
69 | - kinda buggy
70 | - no tests
71 | - options missing
72 | - ES6 compalibity unknown
73 |
74 | ## License
75 |
76 | MIT
--------------------------------------------------------------------------------
/example/app.js:
--------------------------------------------------------------------------------
1 | Vue.use(editable,{
2 | css: {
3 | input: "form-control vue-editable-input-width",
4 | hidden: "vue-editable-hidden",
5 | editable: "vue-editable-can-edit"
6 | }
7 | });
8 | app = new Vue({
9 | el: '.vue',
10 | data: {
11 | message: 'You can change this value',
12 | frank: 1000,
13 | susanne: 1000,
14 | number: 244,
15 | nested:{
16 | obj:{
17 | message: 'nested Information'
18 | }
19 | },
20 | table: [
21 | 500,
22 | 600
23 | ],
24 | staff: [
25 | {
26 | "name":"Frank",
27 | "income":1000,
28 | "car":true
29 | },{
30 | "name":"Susanne",
31 | "income":1000,
32 | "car":false
33 | }
34 | ]
35 | }
36 | });
37 | app.$on("editable-changed",function(e){
38 | console.log(e);
39 | });
40 |
41 | app.$on("editable-opened",function(e){
42 | console.log(e);
43 | });
44 |
45 | app.$on("editable-aborted",function(e){
46 | console.log(e);
47 | });
48 |
--------------------------------------------------------------------------------
/example/example.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmllr/vue-editable/9e57b066b9024def2421b5b6deab1b85ab7f903e/example/example.gif
--------------------------------------------------------------------------------
/example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
vue-editable
14 | vue-editable is a component to manipulate data values in the view without the need to develop an edit dialog.
15 |
Basic example
16 |
17 | Use v-editable='property' to enable editing. property is the property name in $.data, it can be an nested path (see Nested example)
18 |
19 |
20 |
Example with additional attributes
21 |
22 | Use data-type='number' to set the input type. Attributes with data- prefix will be forwarded to the input, e.g.
23 |
24 |
min -> data-min
25 |
max -> data-max
26 |
name -> data-name
27 |
28 |
29 |
30 |
Table
31 |
32 | If you are using v-for, it is a little bit more complicated. You need to tell vue-editable the property you want to update and the index of the element itself.
33 | You can do this with the attributes data-property and data-index.
34 |
35 |
36 |
37 |
Name
38 |
Income
39 |
Car present?
40 |
41 |
42 |
{{ value.name }}
43 |
{{ value.income }}
44 |
{{ value.car }}
45 |
46 |
47 |
48 | If you are just iterating plain arrays, just remove data-property.
49 |
50 |
51 |
52 |
Value
53 |
54 |
55 |
{{ value }}
56 |
57 |
58 |
Nested example
59 |
60 | {{
61 | JSON.stringify(nested)
62 | }}
63 |
64 |
65 | Use v-editable="nested.obj.message" to map the nested structure.
66 |