Skip to content

Commit

Permalink
Add type: object for schema.
Browse files Browse the repository at this point in the history
  • Loading branch information
furybean committed Feb 17, 2016
1 parent 7194b23 commit a481d17
Show file tree
Hide file tree
Showing 12 changed files with 190 additions and 175 deletions.
3 changes: 0 additions & 3 deletions examples/form/field.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
import { default as schema } from './schema';
export default {
methods: {
},
data() {
return {
model: schema.newModel(),
Expand Down
4 changes: 0 additions & 4 deletions src/basic/dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
height: {}
},
beforeCompile() {
console.log(this.$options);
},
computed: {
popupOptions() {
return {
Expand Down
21 changes: 3 additions & 18 deletions src/data/grid-body.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,7 @@
</style>

<script type="text/ecmascript-6">
let getPath = function(object, sortKey) {
if (!object || !sortKey) return null;
var path = sortKey.split('.');
if (path.length === 1) return object[sortKey];
var target = object;
for (var i = 0, j = path.length; i < j; i++) {
var key = path[i];
var value = target[key];
if (i === j - 1) {
return value;
}
if (value === null || value === undefined) return null;
target = value;
}
};
import { getPath } from '../util';
let isObject = function(obj) {
return obj !== null && typeof obj === 'object';
Expand Down Expand Up @@ -106,12 +91,12 @@
if (schema) {
var mapping = schema.getPropertyMapping(property);
if (mapping) {
return schema.translateProperty(property, row[property]);
return schema.translateProperty(property, getPath(row, property));
}
return schema.getPropertyText(row, property);
}
return row[property];
return getPath(row, property);
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/form/checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
.d-checkbox-label {
display: inline-block;
height: 28px;
vertical-align: middle;
vertical-align: top;
font-size: 14px;
}
</style>
Expand Down
1 change: 0 additions & 1 deletion src/form/fields/field-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export default {
if (schema) {
schema.validateProperty(model, this.property);

this.hintType = model.$hintTypes[this.property];
this.hintMessage = model.$hints[this.property];
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/form/fields/field.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,22 @@
overflow: hidden;
text-overflow: ellipsis;
width: 120px;
height: 30px;
height: 28px;
padding-right: 10px;
font-size: 14px;
line-height: 30px;
line-height: 28px;
text-align: right;
color: #666;
}
.d-field-content {
vertical-align: top;
font-size: 14px;
padding-left: 4px;
padding-right: 24px;
box-sizing: border-box;
border-radius: 2px;
line-height: 28px;
}
.d-field.validate-error input {
Expand Down
25 changes: 14 additions & 11 deletions src/form/fields/label.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
.d-labelfield-content {
font-size: 14px;
padding-left: 4px;
width: 100%;
padding-right: 24px;
box-sizing: border-box;
border-radius: 2px;
Expand All @@ -30,7 +29,7 @@
</style>

<script type="text/ecmascript-6">
import { merge } from '../../util';
import { merge, getPath } from '../../util';
import { default as common } from './field-common';
export default {
Expand All @@ -39,19 +38,23 @@
computed: merge({
textValue() {
var mapping = this.mapping;
var reversedMap = {};
if (mapping) {
var reversedMap = {};
for (var label in mapping) {
if (mapping.hasOwnProperty(label)) {
var value = mapping[label];
reversedMap[value] = label;
for (var label in mapping) {
if (mapping.hasOwnProperty(label)) {
var value = mapping[label];
reversedMap[value] = label;
}
}
}
var currentValue = this.model[this.property];
if (mapping && currentValue !== null && currentValue !== undefined) {
return reversedMap[currentValue];
var currentValue = getPath(this.model, this.property);
if (mapping && currentValue !== null && currentValue !== undefined) {
return reversedMap[currentValue];
}
}
return getPath(this.model, this.property);
}
}, common.computed),
Expand Down
6 changes: 3 additions & 3 deletions src/form/fields/radio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</style>

<script type="text/ecmascript-6">
import { merge } from '../../util';
import { merge, getPath, setPath } from '../../util';
import { default as common } from './field-common';
export default {
Expand All @@ -41,12 +41,12 @@
editorValue: {
get() {
if (this.model && this.property) {
return this.model[this.property];
return getPath(this.model, this.property);
}
},
set(newValue) {
if (this.model && this.property) {
this.model[this.property] = newValue;
setPath(this.model, this.property, newValue);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/form/fields/select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</style>

<script type="text/ecmascript-6">
import { merge } from '../../util';
import { merge, getPath, setPath } from '../../util';
import { default as common } from './field-common';
import { default as Dropdown } from '../../service/dropdown';
Expand Down Expand Up @@ -113,12 +113,12 @@
selectValue: {
get() {
if (this.model && this.property) {
return this.model[this.property];
return getPath(this.model, this.property);
}
},
set(newValue) {
if (this.model && this.property) {
this.model[this.property] = newValue;
setPath(this.model, this.property, newValue);
}
}
}
Expand Down
Loading

0 comments on commit a481d17

Please sign in to comment.