@mongoosejs/studio 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -47,6 +47,9 @@ module.exports = app => app.component('document', {
47
47
  if (path.instance == 'Number') {
48
48
  return 'edit-number';
49
49
  }
50
+ if (path.instance === 'Array') {
51
+ return 'edit-array';
52
+ }
50
53
  return 'edit-default';
51
54
  },
52
55
  getEditValueForPath({ path }) {
@@ -0,0 +1,3 @@
1
+ .edit-array button {
2
+ margin-top: 0.5em;
3
+ }
@@ -0,0 +1,9 @@
1
+ <div class="edit-array">
2
+ <div v-for="(el, i) in currentValue">
3
+ <input type="text" :value="el" @input="currentValue[i] = $event.target.value; onUpdate()">
4
+ <span style="cursor: pointer; color: #880000; font-weight: bold;" @click="removeValue(i)">&times;</span>
5
+ </div>
6
+ <div>
7
+ <button @click="currentValue.push(''); onUpdate();">Add</button>
8
+ </div>
9
+ </div>
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ const template = require('./edit-array.html');
4
+
5
+ const appendCSS = require('../appendCSS');
6
+ appendCSS(require('./edit-array.css'));
7
+
8
+ module.exports = app => app.component('edit-array', {
9
+ template: template,
10
+ props: ['value'],
11
+ data: () => ({ currentValue: null }),
12
+ mounted() {
13
+ this.currentValue = this.value;
14
+ },
15
+ methods: {
16
+ onUpdate() {
17
+ this.$emit('input', this.currentValue);
18
+ },
19
+ removeValue(i) {
20
+ this.currentValue.splice(i, 1);
21
+ this.$emit('input', this.currentValue);
22
+ }
23
+ },
24
+ emits: ['input']
25
+ });
@@ -1,3 +1,3 @@
1
1
  <div>
2
- <input type="datetime-local" :value="value" @input="$emit('input', $event.target.value)">
2
+ <input type="datetime-local" :value="valueAsLocalString" @input="$emit('input', $event.target.value)">
3
3
  </div>
@@ -5,5 +5,24 @@ const template = require('./edit-date.html');
5
5
  module.exports = app => app.component('edit-date', {
6
6
  template: template,
7
7
  props: ['value'],
8
- emits: ['input']
8
+ emits: ['input'],
9
+ computed: {
10
+ valueAsLocalString() {
11
+ if (this.value == null) {
12
+ return this.value;
13
+ }
14
+ const date = new Date(this.value);
15
+ return [
16
+ date.getFullYear(),
17
+ '-',
18
+ (date.getMonth() + 1).toString().padStart(2, '0'),
19
+ '-',
20
+ date.getDate().toString().padStart(2, '0'),
21
+ 'T',
22
+ date.getHours().toString().padStart(2, '0'),
23
+ ':',
24
+ date.getMinutes().toString().padStart(2, '0')
25
+ ].join('');
26
+ }
27
+ }
9
28
  });
@@ -8,6 +8,7 @@ require('./async-button/async-button')(app);
8
8
  require('./detail-array/detail-array')(app);
9
9
  require('./detail-default/detail-default')(app);
10
10
  require('./document/document')(app);
11
+ require('./edit-array/edit-array')(app);
11
12
  require('./edit-default/edit-default')(app);
12
13
  require('./edit-number/edit-number')(app);
13
14
  require('./edit-date/edit-date')(app);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongoosejs/studio",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "dependencies": {
5
5
  "archetype": "0.13.0",
6
6
  "csv-stringify": "6.3.0",