Merge branch 'develop' into tests
This commit is contained in:
commit
1181046589
|
@ -1691,6 +1691,7 @@
|
|||
"requires": {
|
||||
"anymatch": "1.3.2",
|
||||
"async-each": "1.0.1",
|
||||
"fsevents": "1.1.3",
|
||||
"glob-parent": "2.0.0",
|
||||
"inherits": "2.0.3",
|
||||
"is-binary-path": "1.0.1",
|
||||
|
@ -3421,6 +3422,910 @@
|
|||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||
},
|
||||
"fsevents": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.3.tgz",
|
||||
"integrity": "sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"nan": "2.8.0",
|
||||
"node-pre-gyp": "0.6.39"
|
||||
},
|
||||
"dependencies": {
|
||||
"abbrev": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"ajv": {
|
||||
"version": "4.11.8",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"co": "4.6.0",
|
||||
"json-stable-stringify": "1.0.1"
|
||||
}
|
||||
},
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"aproba": {
|
||||
"version": "1.1.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"are-we-there-yet": {
|
||||
"version": "1.1.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"delegates": "1.0.0",
|
||||
"readable-stream": "2.2.9"
|
||||
}
|
||||
},
|
||||
"asn1": {
|
||||
"version": "0.2.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"assert-plus": {
|
||||
"version": "0.2.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"asynckit": {
|
||||
"version": "0.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"aws-sign2": {
|
||||
"version": "0.6.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"aws4": {
|
||||
"version": "1.6.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "0.4.2",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"bcrypt-pbkdf": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"tweetnacl": "0.14.5"
|
||||
}
|
||||
},
|
||||
"block-stream": {
|
||||
"version": "0.0.9",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"inherits": "2.0.3"
|
||||
}
|
||||
},
|
||||
"boom": {
|
||||
"version": "2.10.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"hoek": "2.16.3"
|
||||
}
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.7",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"balanced-match": "0.4.2",
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"buffer-shims": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"caseless": {
|
||||
"version": "0.12.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"co": {
|
||||
"version": "4.6.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"combined-stream": {
|
||||
"version": "1.0.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"delayed-stream": "1.0.0"
|
||||
}
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"cryptiles": {
|
||||
"version": "2.0.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"boom": "2.10.1"
|
||||
}
|
||||
},
|
||||
"dashdash": {
|
||||
"version": "1.14.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"assert-plus": "1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"assert-plus": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"debug": {
|
||||
"version": "2.6.8",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"deep-extend": {
|
||||
"version": "0.4.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"delegates": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"detect-libc": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"ecc-jsbn": {
|
||||
"version": "0.1.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"jsbn": "0.1.1"
|
||||
}
|
||||
},
|
||||
"extend": {
|
||||
"version": "3.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"extsprintf": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"forever-agent": {
|
||||
"version": "0.6.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"form-data": {
|
||||
"version": "2.1.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"asynckit": "0.4.0",
|
||||
"combined-stream": "1.0.5",
|
||||
"mime-types": "2.1.15"
|
||||
}
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"fstream": {
|
||||
"version": "1.0.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"graceful-fs": "4.1.11",
|
||||
"inherits": "2.0.3",
|
||||
"mkdirp": "0.5.1",
|
||||
"rimraf": "2.6.1"
|
||||
}
|
||||
},
|
||||
"fstream-ignore": {
|
||||
"version": "1.0.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"fstream": "1.0.11",
|
||||
"inherits": "2.0.3",
|
||||
"minimatch": "3.0.4"
|
||||
}
|
||||
},
|
||||
"gauge": {
|
||||
"version": "2.7.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"aproba": "1.1.1",
|
||||
"console-control-strings": "1.1.0",
|
||||
"has-unicode": "2.0.1",
|
||||
"object-assign": "4.1.1",
|
||||
"signal-exit": "3.0.2",
|
||||
"string-width": "1.0.2",
|
||||
"strip-ansi": "3.0.1",
|
||||
"wide-align": "1.1.2"
|
||||
}
|
||||
},
|
||||
"getpass": {
|
||||
"version": "0.1.7",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"assert-plus": "1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"assert-plus": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fs.realpath": "1.0.0",
|
||||
"inflight": "1.0.6",
|
||||
"inherits": "2.0.3",
|
||||
"minimatch": "3.0.4",
|
||||
"once": "1.4.0",
|
||||
"path-is-absolute": "1.0.1"
|
||||
}
|
||||
},
|
||||
"graceful-fs": {
|
||||
"version": "4.1.11",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"har-schema": {
|
||||
"version": "1.0.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"har-validator": {
|
||||
"version": "4.2.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ajv": "4.11.8",
|
||||
"har-schema": "1.0.5"
|
||||
}
|
||||
},
|
||||
"has-unicode": {
|
||||
"version": "2.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"hawk": {
|
||||
"version": "3.1.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"boom": "2.10.1",
|
||||
"cryptiles": "2.0.5",
|
||||
"hoek": "2.16.3",
|
||||
"sntp": "1.0.9"
|
||||
}
|
||||
},
|
||||
"hoek": {
|
||||
"version": "2.16.3",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"http-signature": {
|
||||
"version": "1.1.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"assert-plus": "0.2.0",
|
||||
"jsprim": "1.4.0",
|
||||
"sshpk": "1.13.0"
|
||||
}
|
||||
},
|
||||
"inflight": {
|
||||
"version": "1.0.6",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"once": "1.4.0",
|
||||
"wrappy": "1.0.2"
|
||||
}
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"is-fullwidth-code-point": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"number-is-nan": "1.0.1"
|
||||
}
|
||||
},
|
||||
"is-typedarray": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"isarray": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"isstream": {
|
||||
"version": "0.1.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"jodid25519": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"jsbn": "0.1.1"
|
||||
}
|
||||
},
|
||||
"jsbn": {
|
||||
"version": "0.1.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"json-schema": {
|
||||
"version": "0.2.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"json-stable-stringify": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"jsonify": "0.0.0"
|
||||
}
|
||||
},
|
||||
"json-stringify-safe": {
|
||||
"version": "5.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"jsonify": {
|
||||
"version": "0.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"jsprim": {
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"assert-plus": "1.0.0",
|
||||
"extsprintf": "1.0.2",
|
||||
"json-schema": "0.2.3",
|
||||
"verror": "1.3.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"assert-plus": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"mime-db": {
|
||||
"version": "1.27.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.15",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"mime-db": "1.27.0"
|
||||
}
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"brace-expansion": "1.1.7"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"node-pre-gyp": {
|
||||
"version": "0.6.39",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"detect-libc": "1.0.2",
|
||||
"hawk": "3.1.3",
|
||||
"mkdirp": "0.5.1",
|
||||
"nopt": "4.0.1",
|
||||
"npmlog": "4.1.0",
|
||||
"rc": "1.2.1",
|
||||
"request": "2.81.0",
|
||||
"rimraf": "2.6.1",
|
||||
"semver": "5.3.0",
|
||||
"tar": "2.2.1",
|
||||
"tar-pack": "3.4.0"
|
||||
}
|
||||
},
|
||||
"nopt": {
|
||||
"version": "4.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"abbrev": "1.1.0",
|
||||
"osenv": "0.1.4"
|
||||
}
|
||||
},
|
||||
"npmlog": {
|
||||
"version": "4.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"are-we-there-yet": "1.1.4",
|
||||
"console-control-strings": "1.1.0",
|
||||
"gauge": "2.7.4",
|
||||
"set-blocking": "2.0.0"
|
||||
}
|
||||
},
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"oauth-sign": {
|
||||
"version": "0.8.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"wrappy": "1.0.2"
|
||||
}
|
||||
},
|
||||
"os-homedir": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"os-tmpdir": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"osenv": {
|
||||
"version": "0.1.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"os-homedir": "1.0.2",
|
||||
"os-tmpdir": "1.0.2"
|
||||
}
|
||||
},
|
||||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"performance-now": {
|
||||
"version": "0.2.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"process-nextick-args": {
|
||||
"version": "1.0.7",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"punycode": {
|
||||
"version": "1.4.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"rc": {
|
||||
"version": "1.2.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"deep-extend": "0.4.2",
|
||||
"ini": "1.3.4",
|
||||
"minimist": "1.2.0",
|
||||
"strip-json-comments": "2.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"minimist": {
|
||||
"version": "1.2.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "2.2.9",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"buffer-shims": "1.0.0",
|
||||
"core-util-is": "1.0.2",
|
||||
"inherits": "2.0.3",
|
||||
"isarray": "1.0.0",
|
||||
"process-nextick-args": "1.0.7",
|
||||
"string_decoder": "1.0.1",
|
||||
"util-deprecate": "1.0.2"
|
||||
}
|
||||
},
|
||||
"request": {
|
||||
"version": "2.81.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"aws-sign2": "0.6.0",
|
||||
"aws4": "1.6.0",
|
||||
"caseless": "0.12.0",
|
||||
"combined-stream": "1.0.5",
|
||||
"extend": "3.0.1",
|
||||
"forever-agent": "0.6.1",
|
||||
"form-data": "2.1.4",
|
||||
"har-validator": "4.2.1",
|
||||
"hawk": "3.1.3",
|
||||
"http-signature": "1.1.1",
|
||||
"is-typedarray": "1.0.0",
|
||||
"isstream": "0.1.2",
|
||||
"json-stringify-safe": "5.0.1",
|
||||
"mime-types": "2.1.15",
|
||||
"oauth-sign": "0.8.2",
|
||||
"performance-now": "0.2.0",
|
||||
"qs": "6.4.0",
|
||||
"safe-buffer": "5.0.1",
|
||||
"stringstream": "0.0.5",
|
||||
"tough-cookie": "2.3.2",
|
||||
"tunnel-agent": "0.6.0",
|
||||
"uuid": "3.0.1"
|
||||
}
|
||||
},
|
||||
"rimraf": {
|
||||
"version": "2.6.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"glob": "7.1.2"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"semver": {
|
||||
"version": "5.3.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"set-blocking": {
|
||||
"version": "2.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"signal-exit": {
|
||||
"version": "3.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"sntp": {
|
||||
"version": "1.0.9",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"hoek": "2.16.3"
|
||||
}
|
||||
},
|
||||
"sshpk": {
|
||||
"version": "1.13.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"asn1": "0.2.3",
|
||||
"assert-plus": "1.0.0",
|
||||
"bcrypt-pbkdf": "1.0.1",
|
||||
"dashdash": "1.14.1",
|
||||
"ecc-jsbn": "0.1.1",
|
||||
"getpass": "0.1.7",
|
||||
"jodid25519": "1.0.2",
|
||||
"jsbn": "0.1.1",
|
||||
"tweetnacl": "0.14.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"assert-plus": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"string-width": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"code-point-at": "1.1.0",
|
||||
"is-fullwidth-code-point": "1.0.0",
|
||||
"strip-ansi": "3.0.1"
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"safe-buffer": "5.0.1"
|
||||
}
|
||||
},
|
||||
"stringstream": {
|
||||
"version": "0.0.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "3.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "2.1.1"
|
||||
}
|
||||
},
|
||||
"strip-json-comments": {
|
||||
"version": "2.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"tar": {
|
||||
"version": "2.2.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"block-stream": "0.0.9",
|
||||
"fstream": "1.0.11",
|
||||
"inherits": "2.0.3"
|
||||
}
|
||||
},
|
||||
"tar-pack": {
|
||||
"version": "3.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"debug": "2.6.8",
|
||||
"fstream": "1.0.11",
|
||||
"fstream-ignore": "1.0.5",
|
||||
"once": "1.4.0",
|
||||
"readable-stream": "2.2.9",
|
||||
"rimraf": "2.6.1",
|
||||
"tar": "2.2.1",
|
||||
"uid-number": "0.0.6"
|
||||
}
|
||||
},
|
||||
"tough-cookie": {
|
||||
"version": "2.3.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"punycode": "1.4.1"
|
||||
}
|
||||
},
|
||||
"tunnel-agent": {
|
||||
"version": "0.6.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "5.0.1"
|
||||
}
|
||||
},
|
||||
"tweetnacl": {
|
||||
"version": "0.14.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"uid-number": {
|
||||
"version": "0.0.6",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"verror": {
|
||||
"version": "1.3.6",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"extsprintf": "1.0.2"
|
||||
}
|
||||
},
|
||||
"wide-align": {
|
||||
"version": "1.1.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"string-width": "1.0.2"
|
||||
}
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"fstream": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz",
|
||||
|
@ -9139,6 +10044,7 @@
|
|||
"anymatch": "2.0.0",
|
||||
"async-each": "1.0.1",
|
||||
"braces": "2.3.0",
|
||||
"fsevents": "1.1.3",
|
||||
"glob-parent": "3.1.0",
|
||||
"inherits": "2.0.3",
|
||||
"is-binary-path": "1.0.1",
|
||||
|
|
|
@ -10,29 +10,60 @@
|
|||
@change="handleChange"
|
||||
:class="{'fields-area-receive': isDraggingFromAvailable}"
|
||||
:list="activeFieldList"
|
||||
:options="{group:'fields', chosenClass: 'sortable-chosen', filter: '.not-sortable-item'}">
|
||||
<div
|
||||
:options="{group: { name:'fields', pull: false, put: true }, 'handle': '.handle', chosenClass: 'sortable-chosen', filter: '.not-sortable-item'}">
|
||||
<div
|
||||
class="active-field-item"
|
||||
:class="{'not-sortable-item': field.id == undefined}"
|
||||
:class="{'not-sortable-item': field.id == undefined || isRepositoryLevel }"
|
||||
v-for="(field, index) in activeFieldList" :key="index">
|
||||
{{ field.name }}
|
||||
<span class="label-details"><span class="loading-spinner" v-if="field.id == undefined"></span> <b-tag v-if="field.status != undefined">{{field.status}}</b-tag></span>
|
||||
<a @click.prevent="removeField(field)" v-if="field.id != undefined"><b-icon icon="delete"></b-icon></a>
|
||||
<b-icon icon="pencil" v-if="field.id != undefined"></b-icon>
|
||||
<div>
|
||||
<div class="handle">
|
||||
{{ field.name }}
|
||||
<span class="label-details"><span class="loading-spinner" v-if="field.id == undefined"></span> <b-tag v-if="field.status != undefined">{{field.status}}</b-tag></span>
|
||||
<b-icon type="is-gray" class="is-pulled-right" icon="drag"></b-icon>
|
||||
<a @click.prevent="removeField(field)" v-if="field.id != undefined"><b-icon icon="delete"></b-icon></a>
|
||||
<a @click.prevent="editField(field)" v-if="field.id != undefined"><b-icon icon="pencil" v-if="field.id != undefined"></b-icon></a>
|
||||
</div>
|
||||
<div v-if="openedFieldId == field.id">
|
||||
<form v-on:submit.prevent="saveEdition($event, field)">
|
||||
<b-field :label="$i18n.get('label_status')">
|
||||
<b-select
|
||||
id="tainacan-select-status"
|
||||
name="status"
|
||||
:value="editForm"
|
||||
:placeholder="$i18n.get('instruction_select_a_status')">
|
||||
<option value="private">{{ $i18n.get('publish')}}</option>
|
||||
<option value="private">{{ $i18n.get('private')}}</option>
|
||||
</b-select>
|
||||
</b-field>
|
||||
|
||||
<div v-html="field.edit_form"></div>
|
||||
|
||||
<div class="field is-grouped">
|
||||
<div class="control">
|
||||
<button class="button is-link" type="submit">Submit</button>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button class="button is-text" @click.prevent="cancelEdition(field)" slot="trigger">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="not-sortable-item" slot="footer">{{ $i18n.get('instruction_dragndrop_fields_collection') }}</div>
|
||||
|
||||
<!-- <div class="not-sortable-item" slot="footer">{{ $i18n.get('instruction_dragndrop_fields_collection') }}</div> -->
|
||||
</draggable>
|
||||
</b-field>
|
||||
</div>
|
||||
<div class="column">
|
||||
<b-field :label="$i18n.get('label_available_fields')">
|
||||
<div class="columns box available-fields-area" >
|
||||
<draggable class="column" :list="availableFieldList" :options="{ sort: false, group: { name:'fields', pull: 'clone', put: 'false', revertClone: 'true' }}">
|
||||
<draggable class="column" :list="availableFieldList" :options="{ sort: false, group: { name:'fields', pull: 'clone', put: false, revertClone: true }}">
|
||||
<div class="available-field-item" v-if="index % 2 == 0" v-for="(field, index) in availableFieldList" :key="index">
|
||||
{{ field.name }} <b-icon type="is-gray" class="is-pulled-right" icon="drag"></b-icon>
|
||||
</div>
|
||||
</draggable>
|
||||
<draggable class="column" :list="availableFieldList" :options="{ sort: false, group: { name:'fields', pull: 'clone', put: 'false', revertClone: 'true' }}">
|
||||
<draggable class="column" :list="availableFieldList" :options="{ sort: false, group: { name:'fields', pull: 'clone', put: false, revertClone: true }}">
|
||||
<div class="available-field-item" v-if="index % 2 != 0" v-for="(field, index) in availableFieldList" :key="index">
|
||||
{{ field.name }} <b-icon type="is-gray" class="is-pulled-right" icon="drag"></b-icon>
|
||||
</div>
|
||||
|
@ -52,20 +83,24 @@ export default {
|
|||
data(){
|
||||
return {
|
||||
collectionId: '',
|
||||
isRepositoryLevel: false,
|
||||
isDraggingFromAvailable: false,
|
||||
isLoadingFieldTypes: true,
|
||||
isLoadingFields: false
|
||||
isLoadingFields: false,
|
||||
isLoadingField: false,
|
||||
editForm: {},
|
||||
openedFieldId: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions('collection', [
|
||||
...mapActions('fields', [
|
||||
'fetchFieldTypes',
|
||||
'fetchFields',
|
||||
'sendField',
|
||||
'deleteField',
|
||||
'updateCollectionFieldsOrder'
|
||||
]),
|
||||
...mapGetters('collection',[
|
||||
...mapGetters('fields',[
|
||||
'getFieldTypes',
|
||||
'getFields'
|
||||
]),
|
||||
|
@ -75,9 +110,25 @@ export default {
|
|||
} else if ($event.removed) {
|
||||
this.removeField($event.removed.element);
|
||||
} else if ($event.moved) {
|
||||
this.updateFieldsOrder();
|
||||
if (!this.isRepositoryLevel)
|
||||
this.updateFieldsOrder();
|
||||
}
|
||||
},
|
||||
saveEdition($event, field) {
|
||||
this.openedFieldId = field.id;
|
||||
|
||||
let data = []
|
||||
for (let i = 0; i < $event.target.length; i++) {
|
||||
let input = {};
|
||||
input[$event.target[i].name] = $event.target[i].value;
|
||||
data.push(input);
|
||||
}
|
||||
console.log(data);
|
||||
},
|
||||
cancelEdition(field) {
|
||||
this.editForm = {};
|
||||
this.openedFieldId = '';
|
||||
},
|
||||
updateFieldsOrder() {
|
||||
let fieldsOrder = [];
|
||||
for (let field of this.activeFieldList) {
|
||||
|
@ -86,26 +137,41 @@ export default {
|
|||
this.updateCollectionFieldsOrder({ collectionId: this.collectionId, fieldsOrder: fieldsOrder });
|
||||
},
|
||||
addNewField(newField, newIndex) {
|
||||
this.sendField({collectionId: this.collectionId, name: newField.name, fieldType: newField.className, status: 'auto-draft'})
|
||||
this.sendField({collectionId: this.collectionId, name: newField.name, fieldType: newField.className, status: 'auto-draft', isRepositoryLevel: this.isRepositoryLevel})
|
||||
.then((field) => {
|
||||
this.activeFieldList.splice(newIndex, 1, field);
|
||||
this.updateFieldsOrder();
|
||||
|
||||
if (newIndex < 0) {
|
||||
this.activeFieldList.pop();
|
||||
this.activeFieldList.push(field);
|
||||
} else {
|
||||
this.activeFieldList.splice(newIndex, 1, field);
|
||||
}
|
||||
|
||||
if (!this.isRepositoryLevel)
|
||||
this.updateFieldsOrder();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
removeField(removedField) {
|
||||
this.deleteField({ collectionId: this.collectionId, fieldId: removedField.id })
|
||||
this.deleteField({ collectionId: this.collectionId, fieldId: removedField.id, isRepositoryLevel: this.isRepositoryLevel})
|
||||
.then((field) => {
|
||||
let index = this.activeFieldList.findIndex(deletedField => deletedField.id === field.id);
|
||||
if (index >= 0) {
|
||||
if (index >= 0)
|
||||
this.activeFieldList.splice(index, 1);
|
||||
}
|
||||
this.updateFieldsOrder();
|
||||
|
||||
if (!this.isRepositoryLevel)
|
||||
this.updateFieldsOrder();
|
||||
})
|
||||
.catch((error) => {
|
||||
});
|
||||
},
|
||||
editField(field) {
|
||||
if (this.openedFieldId == field.id)
|
||||
this.openedFieldId = '';
|
||||
else
|
||||
this.openedFieldId = field.id;
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -118,10 +184,8 @@ export default {
|
|||
},
|
||||
created() {
|
||||
this.isLoadingFieldTypes = true;
|
||||
this.isLoadingFields = true;
|
||||
this.isLoadingFields = true;
|
||||
|
||||
this.collectionId = this.$route.params.collectionId;
|
||||
|
||||
this.fetchFieldTypes()
|
||||
.then((res) => {
|
||||
this.isLoadingFieldTypes = false;
|
||||
|
@ -129,7 +193,11 @@ export default {
|
|||
.catch((error) => {
|
||||
this.isLoadingFieldTypes = false;
|
||||
});
|
||||
this.fetchFields(this.collectionId)
|
||||
|
||||
this.isRepositoryLevel = this.$route.name == 'FieldsPage' ? true : false;
|
||||
this.collectionId = this.$route.params.collectionId;
|
||||
|
||||
this.fetchFields({collectionId: this.collectionId, isRepositoryLevel: this.isRepositoryLevel})
|
||||
.then((res) => {
|
||||
this.isLoadingFields = false;
|
||||
})
|
||||
|
@ -153,6 +221,10 @@ export default {
|
|||
border: 1px dashed gray;
|
||||
}
|
||||
|
||||
.collapse {
|
||||
display: initial;
|
||||
}
|
||||
|
||||
.active-field-item {
|
||||
background-color: white;
|
||||
padding: 0.2em 0.5em;
|
||||
|
@ -182,7 +254,7 @@ export default {
|
|||
|
||||
&.not-sortable-item {
|
||||
color: gray;
|
||||
cursor: wait;
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
.active-field-item:hover {
|
||||
|
|
|
@ -126,6 +126,12 @@ export default {
|
|||
'getItems',
|
||||
'getFields'
|
||||
]),
|
||||
...mapActions('fields', [
|
||||
'fetchFields'
|
||||
]),
|
||||
...mapGetters('fields', [
|
||||
'getFields'
|
||||
]),
|
||||
deleteOneItem(itemId) {
|
||||
this.$dialog.confirm({
|
||||
message: this.$i18n.get('info_warning_item_delete'),
|
||||
|
@ -191,8 +197,9 @@ export default {
|
|||
handleSelectionChange() {
|
||||
},
|
||||
onChangeItemsPerPage(value) {
|
||||
let prevValue = this.itemsPerPage;
|
||||
this.itemsPerPage = value;
|
||||
this.$userPrefs.set('items_per_page', value);
|
||||
this.$userPrefs.set('num_items_per_page', value, prevValue);
|
||||
this.loadItems();
|
||||
},
|
||||
goToItemPage(itemId) {
|
||||
|
@ -223,17 +230,17 @@ export default {
|
|||
}
|
||||
},
|
||||
created() {
|
||||
this.$userPrefs.get('items_per_page')
|
||||
this.$userPrefs.get('num_items_per_page')
|
||||
.then((value) => {
|
||||
this.itemsPerPage = value;
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$userPrefs.set('items_per_page', 12);
|
||||
this.$userPrefs.set('num_items_per_page', 12, null);
|
||||
});
|
||||
},
|
||||
mounted(){
|
||||
this.loadItems();
|
||||
this.fetchFields(this.collectionId).then((res) => {
|
||||
this.fetchFields({ collectionId: this.collectionId, isRepositoryLevel: false }).then((res) => {
|
||||
let rawFields = res;
|
||||
for (let field of rawFields) {
|
||||
this.tableFields.push(
|
||||
|
|
|
@ -29,22 +29,29 @@ UserPrefsPlugin.install = function (Vue, options = {}) {
|
|||
return new Promise(( resolve, reject ) => {
|
||||
wpApi.get('/wp/v2/users/me/')
|
||||
.then( res => {
|
||||
if (res.data.meta.hasOwnProperty(key))
|
||||
resolve( res.data.key );
|
||||
else
|
||||
if (res.data.meta.hasOwnProperty(key)) {
|
||||
if (res.data.key.length > 1)
|
||||
resolve( res.data.key );
|
||||
else
|
||||
resolve( res.data.key[0] );
|
||||
} else {
|
||||
reject( { message: 'Key does not exists in user preference.', value: false} );
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
reject( { message: error, value: false});
|
||||
});
|
||||
});
|
||||
},
|
||||
set(metakey, value) {
|
||||
let data = {
|
||||
'meta': { metakey: value }
|
||||
};
|
||||
set(metakey, value, prevValue) {
|
||||
let data = {}
|
||||
if (prevValue != null)
|
||||
data = {'meta': [{'metakey': metakey, 'metavalue': value, 'prevvalue': prevValue}]};
|
||||
else
|
||||
data = {'meta': [{'metakey': metakey, 'metavalue': value}]};
|
||||
|
||||
return new Promise(( resolve, reject ) => {
|
||||
wpApi.post('/wp/v2/users/me/?context=edit&' + qs.stringify(data))
|
||||
wpApi.post('/wp/v2/users/me/?' + qs.stringify(data))
|
||||
.then( res => {
|
||||
resolve( res.data );
|
||||
})
|
||||
|
|
|
@ -5,17 +5,23 @@
|
|||
<router-link tag="button" class="button is-secondary"
|
||||
:to="{ path: $routerHelper.getNewFieldPath() }">
|
||||
{{ $i18n.get('new') + ' ' + $i18n.get('field') }}
|
||||
</router-link>
|
||||
</router-link>
|
||||
<fields-list></fields-list>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import FieldsList from '../../components/fields-list.vue';
|
||||
|
||||
export default {
|
||||
name: 'FieldsPage',
|
||||
data(){
|
||||
return {
|
||||
}
|
||||
},
|
||||
components: {
|
||||
FieldsList
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -2,6 +2,22 @@
|
|||
|
||||
class TAINACAN_REST_Controller extends WP_REST_Controller {
|
||||
|
||||
|
||||
/**
|
||||
* TAINACAN_REST_Controller constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'rest_api_init', function () {
|
||||
register_rest_field( 'user',
|
||||
'meta',
|
||||
array(
|
||||
'update_callback' => array($this, 'up_user_meta'),
|
||||
'get_callback' => array($this, 'gt_user_meta'),
|
||||
)
|
||||
);
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @param $new_values
|
||||
|
@ -105,6 +121,73 @@ class TAINACAN_REST_Controller extends WP_REST_Controller {
|
|||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param $field_name
|
||||
* @param $request
|
||||
*
|
||||
* @return WP_Error
|
||||
*/
|
||||
function gt_user_meta( $data, $field_name, $request ) {
|
||||
if( $data['id'] ){
|
||||
$user_meta = get_user_meta( $data['id'] );
|
||||
}
|
||||
|
||||
if ( !$user_meta ) {
|
||||
return new WP_Error( 'No user meta found', 'No user meta found', array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
foreach ($user_meta as $key => $value) {
|
||||
$data[$key] = $value;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $meta
|
||||
* @param $user
|
||||
* @param $field_name
|
||||
*
|
||||
* @return mixed|WP_Error
|
||||
*/
|
||||
public function up_user_meta( $meta, $user, $field_name ) {
|
||||
if ( !$user->ID ) {
|
||||
return new WP_Error( 'No user found', 'No user found', array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$user_id = $user->ID;
|
||||
$metas = $field_name === 'meta' ? $meta : '';
|
||||
|
||||
$map = [
|
||||
'metakey',
|
||||
'metavalue',
|
||||
'prevvalue',
|
||||
];
|
||||
|
||||
if($this->contains_array($metas, $map)){
|
||||
foreach ($metas as $index => $meta){
|
||||
if(isset($meta[$map[0]], $meta[$map[1]], $meta[$map[2]])){
|
||||
|
||||
update_user_meta($user_id, $meta[$map[0]], $meta[$map[1]], $meta[$map[2]]);
|
||||
} elseif (isset($meta[$map[0]], $meta[$map[1]])){
|
||||
|
||||
add_user_meta($user_id, $meta[$map[0]], $meta[$map[1]]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($metas as $meta){
|
||||
if(isset($meta[$map[0]], $meta[$map[1]], $meta[$map[2]])){
|
||||
|
||||
update_user_meta($user_id, $meta[$map[0]], $meta[$map[1]], $meta[$map[2]]);
|
||||
} elseif (isset($meta[$map[0]], $meta[$map[1]])){
|
||||
|
||||
add_user_meta($user_id, $meta[$map[0]], $meta[$map[1]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $mapped
|
||||
* @param $request
|
||||
|
|
|
@ -54,9 +54,9 @@ class TAINACAN_REST_Fields_Controller extends TAINACAN_REST_Controller {
|
|||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array($this, 'get_all_field_values'),
|
||||
'permission_callback' => array($this, 'get_all_field_values_permissions_check')
|
||||
)
|
||||
'callback' => array($this, 'get_item'),
|
||||
'permission_callback' => array($this, 'get_item_permissions_check')
|
||||
),
|
||||
)
|
||||
);
|
||||
register_rest_route($this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base,
|
||||
|
@ -80,6 +80,11 @@ class TAINACAN_REST_Fields_Controller extends TAINACAN_REST_Controller {
|
|||
'methods' => WP_REST_Server::CREATABLE,
|
||||
'callback' => array($this, 'create_item'),
|
||||
'permission_callback' => array($this, 'create_item_permissions_check')
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array($this, 'get_items'),
|
||||
'permission_callback' => array($this, 'get_items_permissions_check')
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -95,7 +100,7 @@ class TAINACAN_REST_Fields_Controller extends TAINACAN_REST_Controller {
|
|||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array($this, 'update_item'),
|
||||
'permission_callback' => array($this, 'update_item_permissions_check')
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -105,7 +110,7 @@ class TAINACAN_REST_Fields_Controller extends TAINACAN_REST_Controller {
|
|||
*
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public function get_all_field_values( $request ) {
|
||||
public function get_item( $request ) {
|
||||
$collection_id = $request['collection_id'];
|
||||
$field_id = $request['field_id'];
|
||||
|
||||
|
@ -115,9 +120,9 @@ class TAINACAN_REST_Fields_Controller extends TAINACAN_REST_Controller {
|
|||
return new WP_REST_Response($results, 200);
|
||||
}
|
||||
|
||||
return new WP_REST_Response([
|
||||
'error_message' => __('Verify the route. A query parameter is missing', 'tainacan'),
|
||||
], 400);
|
||||
$result = $this->field_repository->fetch($field_id, 'OBJECT');
|
||||
|
||||
return new WP_REST_Response($this->prepare_item_for_response($result, $request), 200);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,13 +131,18 @@ class TAINACAN_REST_Fields_Controller extends TAINACAN_REST_Controller {
|
|||
* @return bool|WP_Error
|
||||
* @throws Exception
|
||||
*/
|
||||
public function get_all_field_values_permissions_check( $request ) {
|
||||
public function get_item_permissions_check( $request ) {
|
||||
$collection = $this->collection_repository->fetch($request['collection_id']);
|
||||
|
||||
if($request['context'] === 'edit' && !$this->field_repository->can_read(new Entities\Field())){
|
||||
return false;
|
||||
if($collection instanceof Entities\Collection) {
|
||||
if ($request['context'] === 'edit' && ! $collection->can_read()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -266,6 +276,11 @@ class TAINACAN_REST_Fields_Controller extends TAINACAN_REST_Controller {
|
|||
|
||||
if($request['context'] === 'edit'){
|
||||
$item_arr['current_user_can_edit'] = $item->can_edit();
|
||||
ob_start();
|
||||
$item->get_field_type_object()->form();
|
||||
$form = ob_get_clean();
|
||||
$item_arr['edit_form'] = $form;
|
||||
|
||||
}
|
||||
|
||||
return $item_arr;
|
||||
|
@ -280,17 +295,31 @@ class TAINACAN_REST_Fields_Controller extends TAINACAN_REST_Controller {
|
|||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public function get_items( $request ) {
|
||||
$collection_id = $request['collection_id'];
|
||||
if(isset($request['collection_id'])) {
|
||||
$collection_id = $request['collection_id'];
|
||||
|
||||
$args = $this->prepare_filters($request);
|
||||
$args = $this->prepare_filters( $request );
|
||||
|
||||
$collection = new Entities\Collection($collection_id);
|
||||
$collection = new Entities\Collection( $collection_id );
|
||||
|
||||
$collection_metadata = $this->field_repository->fetch_by_collection($collection, $args, 'OBJECT');
|
||||
$result = $this->field_repository->fetch_by_collection( $collection, $args, 'OBJECT' );
|
||||
} else {
|
||||
$args = [
|
||||
'meta_query' => [
|
||||
[
|
||||
'key' => 'collection_id',
|
||||
'value' => 'default',
|
||||
'compare' => '='
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$result = $this->field_repository->fetch( $args, 'OBJECT' );
|
||||
}
|
||||
|
||||
$prepared_item = [];
|
||||
foreach ($collection_metadata as $item){
|
||||
$prepared_item[] = $this->prepare_item_for_response($item, $request);
|
||||
foreach ( $result as $item ) {
|
||||
$prepared_item[] = $this->prepare_item_for_response( $item, $request );
|
||||
}
|
||||
|
||||
return new WP_REST_Response($prepared_item, 200);
|
||||
|
@ -303,18 +332,11 @@ class TAINACAN_REST_Fields_Controller extends TAINACAN_REST_Controller {
|
|||
* @throws Exception
|
||||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if (isset($request['collection_id'])) {
|
||||
|
||||
|
||||
if ( 'edit' === $request['context'] && ! current_user_can('edit_tainacan-fields') ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
if ( 'edit' === $request['context'] && ! current_user_can('edit_tainacan-fields') ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -75,6 +75,11 @@ class Filter extends Entity {
|
|||
*/
|
||||
function get_filter_type_object(){
|
||||
$class_name = $this->get_filter_type();
|
||||
|
||||
if( !class_exists( $class_name ) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
$object_type = new $class_name();
|
||||
$object_type->set_options( $this->get_filter_options() );
|
||||
return $object_type;
|
||||
|
@ -158,4 +163,34 @@ class Filter extends Entity {
|
|||
public function set_filter_type($value){
|
||||
$this->set_mapped_property('filter_type', ( is_object( $value ) ) ? get_class( $value ) : $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc }
|
||||
*
|
||||
* Also validates the field, calling the validate_options callback of the Field Type
|
||||
*
|
||||
* @return bool valid or not
|
||||
*/
|
||||
public function validate() {
|
||||
$is_valid = parent::validate();
|
||||
if (false === $is_valid)
|
||||
return false;
|
||||
|
||||
$fto = $this->get_filter_type_object();
|
||||
if (is_object($fto)) {
|
||||
$is_valid = $fto->validate_options( $this );
|
||||
}
|
||||
|
||||
if (true === $is_valid)
|
||||
return true;
|
||||
|
||||
if (!is_array($is_valid))
|
||||
throw new \Exception("Return of validate_options field type method should be an Array in case of error");
|
||||
|
||||
foreach ($is_valid as $field => $message) {
|
||||
$this->add_error($field, $message);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -47,29 +47,33 @@ class Category extends Field_Type {
|
|||
// TODO: form incomplete and not tested
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<label><?php echo __('Category','tainacan'); ?></label><br/>
|
||||
<small><?php echo __('Select the category','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<select name="taxonomy_id">
|
||||
<?php foreach ($taxonomies as $tax): ?>
|
||||
|
||||
<option value="<?php echo $tax->get_db_identifier(); ?>" <?php selected($this->get_option('taxonomy_id'), $tax->get_db_identifier()); ?> ><?php echo $tax->get_name(); ?></option>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<label><?php echo __('Allow creation of new terms','tainacan'); ?></label><br/>
|
||||
<small><?php echo __('If checked, users may create new terms for this category, otherwise they can only selected from existing terms.','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" name="allow_new_terms" <?php checked(true, $this->get_option('allow_new_terms')); ?> >
|
||||
<label>Allow</label>
|
||||
</td>
|
||||
</tr>
|
||||
<div class="field">
|
||||
<label class="label">
|
||||
<?php _e('Category','tainacan'); ?>
|
||||
</label>
|
||||
|
||||
<div class="control">
|
||||
<div class="select">
|
||||
<select name="field_type_options[taxonomy_id]">
|
||||
<?php foreach ($taxonomies as $tax): ?>
|
||||
|
||||
<option value="<?php echo $tax->get_db_identifier(); ?>" <?php selected($this->get_option('taxonomy_id'), $tax->get_db_identifier()); ?> ><?php echo $tax->get_name(); ?></option>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="field_type_options[allow_new_terms]" <?php checked(true, $this->get_option('allow_new_terms')); ?> >
|
||||
Allow
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class Checkbox extends Field_Type {
|
|||
*/
|
||||
|
||||
public function render( $itemMetadata ){
|
||||
$options = ( isset( $this->options['options'] ) ) ? $this->options['options'] : '';
|
||||
$options = $this->get_option('options');
|
||||
return '<tainacan-checkbox options="'.$options.'"
|
||||
field_id ="'.$itemMetadata->get_field()->get_id().'"
|
||||
item_id="'.$itemMetadata->get_item()->get_id().'"
|
||||
|
@ -41,7 +41,7 @@ class Checkbox extends Field_Type {
|
|||
<small><?php echo __('Insert the options, separate by lines for the field value','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<textarea name="field_type_checkbox[options]"><?php echo ( isset( $this->options['options'] ) ) ? $this->options['options'] : ''; ?></textarea>
|
||||
<textarea name="field_type_options[options]"><?php echo $this->get_option('options'); ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
|
@ -33,7 +33,7 @@ class Date extends Field_Type {
|
|||
* generate the fields for this field type
|
||||
*/
|
||||
public function form(){
|
||||
$approx_date = ( $this->options['approximate_date'] ) ? $this->options['approximate_date'] : '';
|
||||
$approx_date = $this->get_option('approximate_date');
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
|
@ -41,7 +41,7 @@ class Date extends Field_Type {
|
|||
<small><?php echo __('Allow format approximate date','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<?php Helpers\HtmlHelpers::radio_field( $approx_date, 'field_type_date[approximate_date]' ) ?>
|
||||
<?php Helpers\HtmlHelpers::radio_field( $approx_date, 'field_type_options[approximate_date]' ) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
|
@ -22,7 +22,7 @@ class Radio extends Field_Type {
|
|||
*/
|
||||
|
||||
public function render( $itemMetadata ){
|
||||
$options = ( isset( $this->options['options'] ) ) ? $this->options['options'] : '';
|
||||
$options = $this->get_option('options');
|
||||
return '<tainacan-radio
|
||||
options="' . $options . '"
|
||||
field_id ="'.$itemMetadata->get_field()->get_id().'"
|
||||
|
@ -42,7 +42,7 @@ class Radio extends Field_Type {
|
|||
<small><?php echo __('Insert the options, separate by lines for the field value','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<textarea name="field_type_radio[options]"><?php echo ( isset( $this->options['options'] ) ) ? $this->options['options'] : ''; ?></textarea>
|
||||
<textarea name="field_type_options[options]"><?php echo $this->get_option('options'); ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
|
@ -12,7 +12,7 @@ class Selectbox extends Field_Type {
|
|||
function __construct(){
|
||||
// call field type constructor
|
||||
parent::__construct();
|
||||
parent::set_primitive_type('');
|
||||
parent::set_primitive_type('string');
|
||||
$this->component = 'tainacan-selectbox';
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ class Selectbox extends Field_Type {
|
|||
*/
|
||||
|
||||
public function render( $itemMetadata ){
|
||||
$options = ( isset( $this->options['options'] ) ) ? $this->options['options'] : '';
|
||||
$options = $this->get_option('options');
|
||||
return '<tainacan-selectbox
|
||||
options="' . $options . '"
|
||||
field_id ="'.$itemMetadata->get_field()->get_id().'"
|
||||
|
@ -42,7 +42,7 @@ class Selectbox extends Field_Type {
|
|||
<small><?php echo __('Insert the options, separate by lines for the field value','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<textarea name="field_type_selectbox[options]"><?php echo ( isset( $this->options['options'] ) ) ? $this->options['options'] : ''; ?></textarea>
|
||||
<textarea name="field_type_options[options]"><?php echo $this->get_option('options'); ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
|
@ -15,8 +15,9 @@ class Custom_Interval extends Filter_Type {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $field
|
||||
* @param $filter
|
||||
* @return string
|
||||
* @internal param $field
|
||||
*/
|
||||
public function render( $filter ){
|
||||
$type = ( $filter->get_field()->get_field_type() === 'Tainacan\Field_Types\Date' ) ? 'date' : 'numeric';
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Filter_Types;
|
||||
use Tainacan\Field_Types;
|
||||
|
||||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
|
@ -64,4 +65,28 @@ abstract class Filter_Type {
|
|||
public function set_options( $options ){
|
||||
$this->options = ( is_array( $options ) ) ? $options : unserialize( $options );
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the options Array
|
||||
*
|
||||
* This method should be declared by each filter type sub classes
|
||||
*
|
||||
* @param \Tainacan\Entities\Filter $filter The field object that is beeing validated
|
||||
* @return true|Array True if options are valid. If invalid, returns an array where keys are the field keys and values are error messages.
|
||||
*/
|
||||
public function validate_options(\Tainacan\Entities\Filter $filter) {
|
||||
$field_type = $filter->get_field()->get_field_type();
|
||||
//if there is no field to validate
|
||||
if( !$field_type ){
|
||||
return true;
|
||||
}
|
||||
|
||||
$class = ( is_object( $field_type ) ) ? $field_type : new $field_type();
|
||||
|
||||
if(in_array( $class->get_primitive_type(), $this->supported_types )){
|
||||
return true;
|
||||
} else {
|
||||
return ['unsupported_type' => __('The field primitive type is not supported by this filter', 'tainacan')];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -326,7 +326,7 @@ class Fields extends Repository {
|
|||
|
||||
if( isset( $args['meta_query'] ) ){
|
||||
$args['meta_query'][] = $meta_query;
|
||||
}else{
|
||||
} elseif(is_array($args)){
|
||||
$args['meta_query'] = array( $meta_query );
|
||||
}
|
||||
|
||||
|
|
|
@ -40,52 +40,6 @@ export const fetchCollections = ({commit} , { page, collectionsPerPage }) => {
|
|||
});
|
||||
}
|
||||
|
||||
export const fetchFields = ({ commit }, id) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get('/collection/'+id+'/fields')
|
||||
.then((res) => {
|
||||
let fields= res.data;
|
||||
commit('setFields', fields);
|
||||
resolve (fields);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export const sendField = ( { commit }, { collectionId, name, fieldType, status }) => {
|
||||
return new Promise(( resolve, reject ) => {
|
||||
axios.post('/collection/'+ collectionId + '/fields/', {
|
||||
name: name,
|
||||
field_type: fieldType,
|
||||
status: status
|
||||
})
|
||||
.then( res => {
|
||||
commit('setField', { collection_id: collectionId, name: name, field_type: fieldType, status: status });
|
||||
resolve( res.data );
|
||||
})
|
||||
.catch(error => {
|
||||
reject( error.response );
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteField = ({ commit }, { collectionId, fieldId }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.delete('/collection/' + collectionId + '/fields/' + fieldId)
|
||||
.then( res => {
|
||||
commit('deleteField', { fieldId } );
|
||||
resolve( res.data );
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
reject( error );
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchCollection = ({ commit }, id) => {
|
||||
return new Promise((resolve, reject) =>{
|
||||
axios.get('/collections/' + id)
|
||||
|
@ -130,20 +84,6 @@ export const updateCollection = ({ commit }, { collection_id, name, description,
|
|||
});
|
||||
}
|
||||
|
||||
export const updateCollectionFieldsOrder = ({ commit }, { collectionId, fieldsOrder }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.patch('/collections/' + collectionId, {
|
||||
fields_order: fieldsOrder
|
||||
}).then( res => {
|
||||
commit('setCollection', res.data);
|
||||
resolve( res.data );
|
||||
}).catch( error => {
|
||||
reject( error.response );
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
export const sendCollection = ( { commit }, { name, description, status }) => {
|
||||
return new Promise(( resolve, reject ) => {
|
||||
axios.post('/collections/', {
|
||||
|
@ -161,22 +101,6 @@ export const sendCollection = ( { commit }, { name, description, status }) => {
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
export const fetchFieldTypes = ({ commit} ) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get('/field-types')
|
||||
.then((res) => {
|
||||
let fieldTypes = res.data;
|
||||
commit('setFieldTypes', fieldTypes);
|
||||
resolve (fieldTypes);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export const setItems = ({ commit }, items ) => {
|
||||
commit('setItems', items);
|
||||
};
|
|
@ -6,14 +6,6 @@ export const getCollections = state => {
|
|||
return state.collections;
|
||||
}
|
||||
|
||||
export const getFields = state => {
|
||||
return state.fields;
|
||||
}
|
||||
|
||||
export const getCollection = state => {
|
||||
return state.collection;
|
||||
}
|
||||
|
||||
export const getFieldTypes = state => {
|
||||
return state.fieldTypes;
|
||||
}
|
|
@ -5,8 +5,6 @@ import * as mutations from './mutations';
|
|||
const state = {
|
||||
items: [],
|
||||
collections: [],
|
||||
fields: [],
|
||||
fieldTypes: [],
|
||||
collection: null
|
||||
};
|
||||
|
||||
|
|
|
@ -9,13 +9,6 @@ export const deleteItem = ( state, item ) => {
|
|||
}
|
||||
}
|
||||
|
||||
export const deleteField = ( state, field ) => {
|
||||
let index = state.fields.findIndex(deletedField => deletedField.id === field.id);
|
||||
if (index >= 0) {
|
||||
state.fields.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
export const deleteCollection = ( state, collection ) => {
|
||||
let index = state.collections.findIndex(deletedCollection => deletedCollection.id === collection.id);
|
||||
if (index >= 0) {
|
||||
|
@ -27,16 +20,6 @@ export const setCollections = (state, collections) => {
|
|||
state.collections = collections;
|
||||
}
|
||||
|
||||
export const setSingleField = (state, field) => {
|
||||
let index = state.fields.findIndex(newField => newField.id === field.id);
|
||||
if ( index >= 0){
|
||||
//state.field[index] = field;
|
||||
Vue.set( state.fields, index, field );
|
||||
} else {
|
||||
state.fields.push( field );
|
||||
}
|
||||
}
|
||||
|
||||
export const setFields = (state, fields) => {
|
||||
state.fields = fields;
|
||||
}
|
||||
|
@ -44,7 +27,3 @@ export const setFields = (state, fields) => {
|
|||
export const setCollection = (state, collection) => {
|
||||
state.collection = collection;
|
||||
}
|
||||
|
||||
export const setFieldTypes = (state, fieldTypes) => {
|
||||
state.fieldTypes = fieldTypes;
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
import axios from '../../../axios/axios';
|
||||
|
||||
export const fetchFields = ({ commit }, {collectionId, isRepositoryLevel}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let endpoint = '';
|
||||
if (!isRepositoryLevel)
|
||||
endpoint = '/collection/' + collectionId + '/fields/';
|
||||
else
|
||||
endpoint = '/fields/';
|
||||
|
||||
axios.get(endpoint + '?context=edit')
|
||||
.then((res) => {
|
||||
let fields= res.data;
|
||||
commit('setFields', fields);
|
||||
resolve (fields);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export const fetchField = ({ commit }, {collectionId, fieldId, isRepositoryLevel}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
let endpoint = '';
|
||||
if (!isRepositoryLevel)
|
||||
endpoint = '/collection/' + collectionId + '/fields/' + fieldId;
|
||||
else
|
||||
endpoint = '/fields/' + fieldId;
|
||||
|
||||
axios.get(endpoint + '?context=edit')
|
||||
.then((res) => {
|
||||
let field = res.data;
|
||||
commit('setSingleField', field);
|
||||
resolve (field);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export const sendField = ( { commit }, { collectionId, name, fieldType, status, isRepositoryLevel }) => {
|
||||
return new Promise(( resolve, reject ) => {
|
||||
let endpoint = '';
|
||||
if (!isRepositoryLevel)
|
||||
endpoint = '/collection/' + collectionId + '/fields/';
|
||||
else
|
||||
endpoint = '/fields/';
|
||||
axios.post(endpoint + '?context=edit', {
|
||||
name: name,
|
||||
field_type: fieldType,
|
||||
status: status
|
||||
})
|
||||
.then( res => {
|
||||
commit('setField', { collection_id: collectionId, name: name, field_type: fieldType, status: status });
|
||||
resolve( res.data );
|
||||
})
|
||||
.catch(error => {
|
||||
reject( error.response );
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteField = ({ commit }, { collectionId, fieldId, isRepositoryLevel }) => {
|
||||
let endpoint = '';
|
||||
if (!isRepositoryLevel)
|
||||
endpoint = '/collection/' + collectionId + '/fields/' + fieldId;
|
||||
else
|
||||
endpoint = '/fields/' + fieldId;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.delete(endpoint)
|
||||
.then( res => {
|
||||
commit('deleteField', { fieldId } );
|
||||
resolve( res.data );
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
reject( error );
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
export const updateCollectionFieldsOrder = ({ commit }, { collectionId, fieldsOrder }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.patch('/collections/' + collectionId, {
|
||||
fields_order: fieldsOrder
|
||||
}).then( res => {
|
||||
commit('setCollection', res.data);
|
||||
resolve( res.data );
|
||||
}).catch( error => {
|
||||
reject( error.response );
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
export const fetchFieldTypes = ({ commit} ) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get('/field-types')
|
||||
.then((res) => {
|
||||
let fieldTypes = res.data;
|
||||
commit('setFieldTypes', fieldTypes);
|
||||
resolve (fieldTypes);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
export const getFields = state => {
|
||||
return state.fields;
|
||||
}
|
||||
|
||||
export const getFieldTypes = state => {
|
||||
return state.fieldTypes;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
import * as actions from './actions';
|
||||
import * as getters from './getters';
|
||||
import * as mutations from './mutations';
|
||||
|
||||
const state = {
|
||||
fields: [],
|
||||
fieldTypes: [],
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions,
|
||||
getters
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
import Vue from 'vue';
|
||||
|
||||
export const deleteField = ( state, field ) => {
|
||||
let index = state.fields.findIndex(deletedField => deletedField.id === field.id);
|
||||
if (index >= 0) {
|
||||
state.fields.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
export const setSingleField = (state, field) => {
|
||||
let index = state.fields.findIndex(newField => newField.id === field.id);
|
||||
if ( index >= 0){
|
||||
//state.field[index] = field;
|
||||
Vue.set( state.fields, index, field );
|
||||
} else {
|
||||
state.fields.push( field );
|
||||
}
|
||||
}
|
||||
|
||||
export const setFields = (state, fields) => {
|
||||
state.fields = fields;
|
||||
}
|
||||
|
||||
export const setFieldTypes = (state, fieldTypes) => {
|
||||
state.fieldTypes = fieldTypes;
|
||||
}
|
|
@ -3,6 +3,7 @@ import Vuex from 'vuex';
|
|||
|
||||
import item from './modules/item/';
|
||||
import collection from './modules/collection/';
|
||||
import fields from './modules/fields/';
|
||||
import filter from './modules/filter/';
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
@ -11,6 +12,7 @@ export default new Vuex.Store({
|
|||
modules: {
|
||||
item,
|
||||
collection,
|
||||
fields,
|
||||
filter
|
||||
}
|
||||
})
|
|
@ -24,7 +24,7 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_UnitApiTestCase {
|
|||
'name' => 'Metadata filtered',
|
||||
'description' => 'Is filtered',
|
||||
'collection_id' => $collection->get_id(),
|
||||
'field_type' => 'Tainacan\Field_Types\Text',
|
||||
'field_type' => 'Tainacan\Field_Types\Numeric',
|
||||
),
|
||||
true,
|
||||
true
|
||||
|
@ -47,7 +47,7 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_UnitApiTestCase {
|
|||
$response = $this->server->dispatch($request);
|
||||
|
||||
$data = $response->get_data();
|
||||
$this->assertTrue(is_array($data) && array_key_exists('filter_type', $data), sprintf('cannot create a range, response: %s', print_r($data, true)));
|
||||
$this->assertTrue(is_array($data) && array_key_exists('filter_type', $data), sprintf('cannot create a custom interval, response: %s', print_r($data, true)));
|
||||
$this->assertEquals('Tainacan\Filter_Types\Custom_Interval', $data['filter_type']);
|
||||
$this->assertEquals('Filter name', $data['name']);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,37 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
|||
$this->assertNotEquals('default', $field_added['collection_id']);
|
||||
}
|
||||
|
||||
public function test_fetch_a_field_from_a_collection(){
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
array(
|
||||
'name' => 'Statement',
|
||||
'description' => 'No Statement'
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$fieldA = $this->tainacan_entity_factory->create_entity(
|
||||
'field',
|
||||
array(
|
||||
'name' => 'Data',
|
||||
'description' => 'Descreve valor do campo data.',
|
||||
'collection' => $collection,
|
||||
'status' => 'publish',
|
||||
'field_type' => 'Tainacan\Field_Types\Text',
|
||||
), true
|
||||
);
|
||||
|
||||
$request = new \WP_REST_Request('GET', $this->namespace . '/collection/' . $collection->get_id() . '/fields/' . $fieldA->get_id());
|
||||
|
||||
$response = $this->server->dispatch($request);
|
||||
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals('Data', $data['name']);
|
||||
$this->assertEquals($fieldA->get_id(), $data['id']);
|
||||
}
|
||||
|
||||
public function test_create_default_field(){
|
||||
$field = json_encode(
|
||||
array(
|
||||
|
@ -67,6 +98,50 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
|||
$this->assertEquals('default', $field_added['collection_id']);
|
||||
}
|
||||
|
||||
public function test_fetch_default_fields(){
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
array(
|
||||
'name' => 'Statement',
|
||||
'description' => 'No Statement'
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$fieldA = $this->tainacan_entity_factory->create_entity(
|
||||
'field',
|
||||
array(
|
||||
'name' => 'Data 1',
|
||||
'description' => 'Descreve valor do campo data.',
|
||||
'collection' => $collection,
|
||||
'status' => 'publish',
|
||||
'field_type' => 'Tainacan\Field_Types\Text',
|
||||
), true
|
||||
);
|
||||
|
||||
$fieldB = $this->tainacan_entity_factory->create_entity(
|
||||
'field',
|
||||
array(
|
||||
'name' => 'Data 2',
|
||||
'description' => 'Descreve valor do campo data.',
|
||||
'collection_id' => 'default',
|
||||
'status' => 'publish',
|
||||
'field_type' => 'Tainacan\Field_Types\Text',
|
||||
), true
|
||||
);
|
||||
|
||||
$request_fetch_defaults = new \WP_REST_Request('GET', $this->namespace . '/fields');
|
||||
|
||||
$response_defaults = $this->server->dispatch($request_fetch_defaults);
|
||||
|
||||
$data = $response_defaults->get_data();
|
||||
|
||||
$this->assertCount(1, $data);
|
||||
|
||||
$this->assertEquals('default', $data[0]['collection_id']);
|
||||
$this->assertEquals('Data 2', $data[0]['name']);
|
||||
}
|
||||
|
||||
public function test_get_item_and_collection_metadata(){
|
||||
global $Tainacan_Item_Metadata;
|
||||
|
||||
|
@ -334,7 +409,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
|||
}
|
||||
|
||||
public function test_fetch_all_field_values(){
|
||||
global $Tainacan_Fields, $Tainacan_Item_Metadata;
|
||||
global $Tainacan_Item_Metadata;
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
|
|
@ -99,9 +99,70 @@ class Filters extends TAINACAN_UnitTestCase {
|
|||
global $Tainacan_Filters;
|
||||
|
||||
$all_filter_types = $Tainacan_Filters->fetch_filter_types();
|
||||
$this->assertEquals( 2, count( $all_filter_types ) );
|
||||
$this->assertEquals( 3, count( $all_filter_types ) );
|
||||
|
||||
$float_filters = $Tainacan_Filters->fetch_supported_filter_types('float');
|
||||
$this->assertTrue( count( $float_filters ) > 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @group filter
|
||||
*/
|
||||
function test_validate_supported_filters(){
|
||||
global $Tainacan_Filters;
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
array(
|
||||
'name' => 'Collection filtered',
|
||||
'description' => 'Is filtered',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$field2 = $this->tainacan_entity_factory->create_entity(
|
||||
'field',
|
||||
array(
|
||||
'name' => 'Other filtered',
|
||||
'description' => 'Is filtered',
|
||||
'field_type' => 'Tainacan\Field_Types\Text',
|
||||
'collection_id' => $collection->get_id()
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$autocomplete = $this->tainacan_filter_factory->create_filter('autocomplete');
|
||||
|
||||
$filter = $this->tainacan_entity_factory->create_entity(
|
||||
'filter',
|
||||
array(
|
||||
'name' => 'filtro',
|
||||
'collection' => $collection,
|
||||
'description' => 'descricao',
|
||||
'field' => $field2,
|
||||
'filter_type' => $autocomplete
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$test = $Tainacan_Filters->fetch( $filter->get_id() );
|
||||
|
||||
$this->assertEquals( 'Tainacan\Filter_Types\Autocomplete', $test->get_filter_type());
|
||||
|
||||
$custom_interval = $this->tainacan_filter_factory->create_filter('custom_interval');
|
||||
|
||||
$this->expectException('ErrorException');
|
||||
$filter2 = $this->tainacan_entity_factory->create_entity(
|
||||
'filter',
|
||||
array(
|
||||
'name' => 'filtro 2',
|
||||
'collection' => $collection,
|
||||
'description' => 'descricao',
|
||||
'field' => $field2,
|
||||
'filter_type' => $custom_interval
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue