Skip to content

Commit

Permalink
chore: Merge branch 'dev' of github.com:fyl080801/vjs-form into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
fyl080801 committed Jul 28, 2020
2 parents 78abc80 + 2fb8203 commit 10e9182
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 22 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vjform",
"description": "Vue JSON Form",
"version": "1.1.0-beta.2",
"version": "1.2.0",
"private": false,
"author": {
"name": "fyl080801",
Expand Down
3 changes: 2 additions & 1 deletion package/features/functional/if.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import feature from "../../feature";

feature
.functional("IF", (logic, v1, v2) => {
return logic ? v1 : v2;
const result = logic ? v1 : v2;
return typeof result === "function" ? result() : result;
})
.withDescription("条件判断");
18 changes: 11 additions & 7 deletions package/features/transform/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,22 @@ function processTransform(field, key, collection) {
item.getter.call(this, key, collection)
);

let result;

if (trans) {
trans.deal.call(this, key, collection);
result = trans.deal.call(this, key, collection);
}

forEach(
trans && trans.convert ? collection[key] : field,
processTransform.bind(this)
);
if (result !== false) {
forEach(
trans && trans.convert ? collection[key] : field,
processTransform.bind(this)
);
}
}

export default function(fields, clone = true) {
const ref = clone ? cloneDeep(fields) : fields;
export default function(obj, clone = true) {
const ref = clone ? cloneDeep(obj) : obj;
forEach(ref, processTransform.bind(this));
return ref;
}
16 changes: 10 additions & 6 deletions package/mixins/listeners.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import transform from "../features/transform";
import { isEmpty } from "lodash-es";
import { isEmpty, get } from "lodash-es";

export default {
data() {
Expand All @@ -21,13 +21,16 @@ export default {
methods: {
regist() {
this.listeners.forEach(listener => {
const transedWatch = transform.call(this.data, {
value: listener.watch
});
if (!listener.watch) {
return;
}

this.listenerStore.push(
this.$watch(
() => transedWatch.value,
() =>
typeof listener.watch === "string"
? get(this.data, listener.watch)
: transform.call(this.data, { value: listener.watch }).value,
() => this.process(listener.actions),
{ deep: listener.deep, immediate: listener.immediate }
)
Expand All @@ -49,7 +52,8 @@ export default {
return;
}

const result = typeof result === "function" ? expression() : expression;
const result =
typeof expression === "function" ? expression() : expression;

if (typeof model === "string" && !isEmpty(model)) {
if (result instanceof Promise) {
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7433,9 +7433,9 @@ lodash.uniq@^4.5.0:
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=

lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5:
version "4.17.15"
resolved "https://registry.npm.taobao.org/lodash/download/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
integrity sha1-tEf2ZwoEVbv+7dETku/zMOoJdUg=
version "4.17.19"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==

log-symbols@^1.0.2:
version "1.0.2"
Expand Down

0 comments on commit 10e9182

Please sign in to comment.