Slug
This commit is contained in:
parent
a7923b0a4d
commit
fb2874783a
|
@ -1388,8 +1388,7 @@
|
|||
"bluebird": {
|
||||
"version": "3.5.1",
|
||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
|
||||
"integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA=="
|
||||
},
|
||||
"bn.js": {
|
||||
"version": "4.11.8",
|
||||
|
@ -1429,6 +1428,11 @@
|
|||
"multicast-dns-service-types": "1.1.0"
|
||||
}
|
||||
},
|
||||
"boolbase": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
|
||||
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
|
||||
},
|
||||
"boom": {
|
||||
"version": "2.10.1",
|
||||
"resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz",
|
||||
|
@ -1727,6 +1731,25 @@
|
|||
"integrity": "sha1-FCD/sQ/URNz8ebQ4kbv//TKoRgA=",
|
||||
"dev": true
|
||||
},
|
||||
"cheerio": {
|
||||
"version": "0.19.0",
|
||||
"resolved": "https://registry.npmjs.org/cheerio/-/cheerio-0.19.0.tgz",
|
||||
"integrity": "sha1-dy5wFfLuKZZQltcepBdbdas1SSU=",
|
||||
"requires": {
|
||||
"css-select": "1.0.0",
|
||||
"dom-serializer": "0.1.0",
|
||||
"entities": "1.1.1",
|
||||
"htmlparser2": "3.8.3",
|
||||
"lodash": "3.10.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash": {
|
||||
"version": "3.10.1",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz",
|
||||
"integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y="
|
||||
}
|
||||
}
|
||||
},
|
||||
"chokidar": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz",
|
||||
|
@ -2313,6 +2336,17 @@
|
|||
"source-list-map": "0.1.8"
|
||||
}
|
||||
},
|
||||
"css-select": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/css-select/-/css-select-1.0.0.tgz",
|
||||
"integrity": "sha1-sRIcpRhI3SZOIkTQWM7iVN7rRLA=",
|
||||
"requires": {
|
||||
"boolbase": "1.0.0",
|
||||
"css-what": "1.0.0",
|
||||
"domutils": "1.4.3",
|
||||
"nth-check": "1.0.1"
|
||||
}
|
||||
},
|
||||
"css-selector-tokenizer": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/css-selector-tokenizer/-/css-selector-tokenizer-0.6.0.tgz",
|
||||
|
@ -2337,6 +2371,11 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"css-what": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/css-what/-/css-what-1.0.0.tgz",
|
||||
"integrity": "sha1-18wt9FGAZm+Z0rFEYmOUaeAPc2w="
|
||||
},
|
||||
"cssesc": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/cssesc/-/cssesc-0.1.0.tgz",
|
||||
|
@ -2839,12 +2878,49 @@
|
|||
"integrity": "sha512-qAoWcNm1zW3LVO0KSblYISM0oLQzlNtns2gd1O/YS3QvFYFidG6lF73fC98fIbfPQkws698L0/URrtmN8+ADbQ==",
|
||||
"dev": true
|
||||
},
|
||||
"dom-serializer": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz",
|
||||
"integrity": "sha1-BzxpdUbOB4DOI75KKOKT5AvDDII=",
|
||||
"requires": {
|
||||
"domelementtype": "1.1.3",
|
||||
"entities": "1.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"domelementtype": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz",
|
||||
"integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs="
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain-browser": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz",
|
||||
"integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==",
|
||||
"dev": true
|
||||
},
|
||||
"domelementtype": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz",
|
||||
"integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI="
|
||||
},
|
||||
"domhandler": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz",
|
||||
"integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=",
|
||||
"requires": {
|
||||
"domelementtype": "1.3.0"
|
||||
}
|
||||
},
|
||||
"domutils": {
|
||||
"version": "1.4.3",
|
||||
"resolved": "https://registry.npmjs.org/domutils/-/domutils-1.4.3.tgz",
|
||||
"integrity": "sha1-CGVRN5bGswYDGFDhdVFrr4C3Km8=",
|
||||
"requires": {
|
||||
"domelementtype": "1.3.0"
|
||||
}
|
||||
},
|
||||
"ecc-jsbn": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz",
|
||||
|
@ -2928,6 +3004,11 @@
|
|||
"tapable": "0.2.8"
|
||||
}
|
||||
},
|
||||
"entities": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz",
|
||||
"integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA="
|
||||
},
|
||||
"errno": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.4.tgz",
|
||||
|
@ -3771,6 +3852,11 @@
|
|||
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=",
|
||||
"dev": true
|
||||
},
|
||||
"fs": {
|
||||
"version": "0.0.1-security",
|
||||
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
|
||||
"integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ="
|
||||
},
|
||||
"fs-extra": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.1.tgz",
|
||||
|
@ -5100,6 +5186,73 @@
|
|||
"integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8=",
|
||||
"dev": true
|
||||
},
|
||||
"html-to-json": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/html-to-json/-/html-to-json-0.6.0.tgz",
|
||||
"integrity": "sha1-cY2ylfPeCpJi1FKPrBqFg35uBrE=",
|
||||
"requires": {
|
||||
"bluebird": "3.5.1",
|
||||
"cheerio": "0.19.0",
|
||||
"lodash": "3.10.1",
|
||||
"request": "2.79.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash": {
|
||||
"version": "3.10.1",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz",
|
||||
"integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y="
|
||||
}
|
||||
}
|
||||
},
|
||||
"htmlparser2": {
|
||||
"version": "3.8.3",
|
||||
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz",
|
||||
"integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=",
|
||||
"requires": {
|
||||
"domelementtype": "1.3.0",
|
||||
"domhandler": "2.3.0",
|
||||
"domutils": "1.5.1",
|
||||
"entities": "1.0.0",
|
||||
"readable-stream": "1.1.14"
|
||||
},
|
||||
"dependencies": {
|
||||
"domutils": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz",
|
||||
"integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=",
|
||||
"requires": {
|
||||
"dom-serializer": "0.1.0",
|
||||
"domelementtype": "1.3.0"
|
||||
}
|
||||
},
|
||||
"entities": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz",
|
||||
"integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY="
|
||||
},
|
||||
"isarray": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
|
||||
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "1.1.14",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
|
||||
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
|
||||
"requires": {
|
||||
"core-util-is": "1.0.2",
|
||||
"inherits": "2.0.3",
|
||||
"isarray": "0.0.1",
|
||||
"string_decoder": "0.10.31"
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "0.10.31",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
|
||||
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
|
||||
}
|
||||
}
|
||||
},
|
||||
"http-deceiver": {
|
||||
"version": "1.2.7",
|
||||
"resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz",
|
||||
|
@ -6646,6 +6799,11 @@
|
|||
"integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=",
|
||||
"dev": true
|
||||
},
|
||||
"net": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/net/-/net-1.0.2.tgz",
|
||||
"integrity": "sha1-0XV+yaf7I3HYPPR1XOPifhCCk4g="
|
||||
},
|
||||
"node-forge": {
|
||||
"version": "0.6.33",
|
||||
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.6.33.tgz",
|
||||
|
@ -6813,6 +6971,14 @@
|
|||
"set-blocking": "2.0.0"
|
||||
}
|
||||
},
|
||||
"nth-check": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.1.tgz",
|
||||
"integrity": "sha1-mSms32KPwsQQmN6rgqxYDPFJquQ=",
|
||||
"requires": {
|
||||
"boolbase": "1.0.0"
|
||||
}
|
||||
},
|
||||
"num2fraction": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/num2fraction/-/num2fraction-1.2.2.tgz",
|
||||
|
@ -9719,6 +9885,11 @@
|
|||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"tls": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/tls/-/tls-0.0.1.tgz",
|
||||
"integrity": "sha1-CrK/WWjXHfL4wOFRXSSiJAuYqsg="
|
||||
},
|
||||
"tmp": {
|
||||
"version": "0.0.31",
|
||||
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz",
|
||||
|
|
|
@ -11,11 +11,15 @@
|
|||
"axios": "^0.17.1",
|
||||
"buefy": "^0.6.3",
|
||||
"bulma": "^0.6.2",
|
||||
"fs": "0.0.1-security",
|
||||
"html-to-json": "^0.6.0",
|
||||
"mdi": "^2.1.99",
|
||||
"moment": "^2.21.0",
|
||||
"net": "^1.0.2",
|
||||
"node-sass": "^4.7.2",
|
||||
"qs": "^6.5.1",
|
||||
"sass-loader": "^6.0.6",
|
||||
"tls": "0.0.1",
|
||||
"vue": "^2.5.13",
|
||||
"vuedraggable": "^2.16.0",
|
||||
"vuex": "^3.0.1"
|
||||
|
|
|
@ -143,14 +143,16 @@ class Admin {
|
|||
}
|
||||
|
||||
$settings = [
|
||||
'root' => esc_url_raw( rest_url() ) . 'tainacan/v2',
|
||||
'root_wp_api' => esc_url_raw( rest_url() ) . 'wp/v2/',
|
||||
'nonce' => wp_create_nonce( 'wp_rest' ),
|
||||
'components' => $components,
|
||||
'i18n' => $tainacan_admin_i18n,
|
||||
'user_caps' => $user_caps,
|
||||
'user_prefs' => $prefs,
|
||||
'base_url' => $TAINACAN_BASE_URL
|
||||
'root' => esc_url_raw( rest_url() ) . 'tainacan/v2',
|
||||
'root_wp_api' => esc_url_raw( rest_url() ) . 'wp/v2/',
|
||||
'wp_ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||
'nonce' => wp_create_nonce( 'wp_rest' ),
|
||||
'sample_permalink_nonce' => wp_create_nonce( 'samplepermalink' ),
|
||||
'components' => $components,
|
||||
'i18n' => $tainacan_admin_i18n,
|
||||
'user_caps' => $user_caps,
|
||||
'user_prefs' => $prefs,
|
||||
'base_url' => $TAINACAN_BASE_URL
|
||||
];
|
||||
|
||||
$maps = [
|
||||
|
|
|
@ -126,10 +126,13 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapGetters } from 'vuex'
|
||||
import { wpAjax } from "../../js/mixins";
|
||||
import { mapActions, mapGetters } from 'vuex';
|
||||
import htmlToJSON from 'html-to-json';
|
||||
|
||||
export default {
|
||||
name: 'CategoryEditionForm',
|
||||
mixins: [ wpAjax ],
|
||||
data(){
|
||||
return {
|
||||
categoryId: Number,
|
||||
|
@ -218,40 +221,25 @@
|
|||
|
||||
this.isUpdatingSlug = true;
|
||||
|
||||
let data = {
|
||||
categoryId: this.categoryId,
|
||||
name: this.form.name,
|
||||
description: this.form.description,
|
||||
//slug: '',
|
||||
status: 'private',
|
||||
allowInsert: this.form.allowInsert
|
||||
};
|
||||
this.$console.log(data);
|
||||
this.getSamplePermalink(this.categoryId, this.form.name, this.form.slug)
|
||||
.then(samplePermalink => {
|
||||
|
||||
this.updateCategory(data)
|
||||
.then(updatedCategory => {
|
||||
this.category = updatedCategory;
|
||||
let promise = htmlToJSON.parse(samplePermalink, {
|
||||
permalink($doc, $) {
|
||||
return $doc.find('#editable-post-name-full').text();
|
||||
}
|
||||
});
|
||||
|
||||
this.$console.info(this.category);
|
||||
|
||||
// Fill this.form data with current data.
|
||||
this.form.name = this.category.name;
|
||||
this.form.slug = this.category.slug;
|
||||
this.form.description = this.category.description;
|
||||
this.form.status = this.category.status;
|
||||
this.allowInsert = this.category.allow_insert;
|
||||
promise.done((result) => {
|
||||
this.form.slug = result.permalink;
|
||||
});
|
||||
|
||||
this.isUpdatingSlug = false;
|
||||
this.formErrorMessage = '';
|
||||
this.editFormErrors = {};
|
||||
})
|
||||
.catch(errors => {
|
||||
for (let error of errors.errors) {
|
||||
for (let attribute of Object.keys(error)) {
|
||||
this.editFormErrors[attribute] = error[attribute];
|
||||
}
|
||||
}
|
||||
this.formErrorMessage = errors.error_message;
|
||||
this.$console.error(errors);
|
||||
|
||||
this.isLoading = false;
|
||||
});
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
import axios from 'axios';
|
||||
import qs from 'qs';
|
||||
|
||||
export const wpAjax = {
|
||||
methods: {
|
||||
getSamplePermalink(id, newTitle, newSlug){
|
||||
let axiosWPAjax = axios.create({
|
||||
baseURL: tainacan_plugin.wp_ajax_url,
|
||||
});
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
axiosWPAjax.post('', qs.stringify({
|
||||
action: 'sample-permalink',
|
||||
post_id: id,
|
||||
new_title: newTitle,
|
||||
new_slug: newSlug,
|
||||
samplepermalinknonce: tainacan_plugin.sample_permalink_nonce,
|
||||
}))
|
||||
.then(res => {
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
|
@ -59,6 +59,9 @@ module.exports = {
|
|||
historyApiFallback: true,
|
||||
noInfo: true
|
||||
},
|
||||
node: {
|
||||
fs: 'empty'
|
||||
},
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
|
|
Loading…
Reference in New Issue