Init events page, Update all dependences, Improve webpack building performance

This commit is contained in:
weryques 2018-04-03 14:55:05 -03:00
parent f1d1d78811
commit b071bf3a00
13 changed files with 946 additions and 642 deletions

250
package-lock.json generated
View File

@ -370,6 +370,7 @@
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz",
"integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==",
"dev": true,
"requires": {
"lodash": "4.17.5"
}
@ -652,27 +653,14 @@
}
},
"babel-loader": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-7.1.2.tgz",
"integrity": "sha512-jRwlFbINAeyDStqK6Dd5YuY0k5YuzQUvlz2ZamuXrXmxav3pNqe9vfJ402+2G+OmlJSXxCOpB6Uz0INM7RQe2A==",
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-7.1.4.tgz",
"integrity": "sha512-/hbyEvPzBJuGpk9o80R0ZyTej6heEOr59GoEUtn8qFKbnx4cJm9FWES6J/iv644sYgrtVw9JJQkjaLW/bqb5gw==",
"dev": true,
"requires": {
"find-cache-dir": "1.0.0",
"loader-utils": "1.1.0",
"mkdirp": "0.5.1"
},
"dependencies": {
"loader-utils": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz",
"integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=",
"dev": true,
"requires": {
"big.js": "3.2.0",
"emojis-list": "2.1.0",
"json5": "0.5.1"
}
}
}
},
"babel-messages": {
@ -1591,9 +1579,9 @@
}
},
"buefy": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/buefy/-/buefy-0.6.3.tgz",
"integrity": "sha512-ApYZo6USz1SjHyziSaZc2osxWYUkCLwfgzVDo7hTtFvqBAjin1xfzoHd7yb/7BTLqAZYwJuHqe44SnLhrU+9fg==",
"version": "0.6.5",
"resolved": "https://registry.npmjs.org/buefy/-/buefy-0.6.5.tgz",
"integrity": "sha512-s8YwVh8LCd61Cddpb4ssZdGwHmAAranRS0zaMFtjjrkFY3xkK/mM9Tex8V4fTmi+S9btw9c80fCI4KDSFwW8ig==",
"requires": {
"bulma": "0.6.2"
}
@ -2071,7 +2059,6 @@
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz",
"integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=",
"dev": true,
"requires": {
"string-width": "1.0.2",
"strip-ansi": "3.0.1",
@ -2091,14 +2078,14 @@
"dev": true
},
"clone-deep": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-0.3.0.tgz",
"integrity": "sha1-NIxhrpzb4O3+BT2R/0zFIdeQ7eg=",
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-2.0.2.tgz",
"integrity": "sha512-SZegPTKjCgpQH63E+eN6mVEEPdQBOUzjyJm5Pora4lrwWRFS8I0QAxV/KD6vV/i0WuijHZWQC1fMsPEdxfdVCQ==",
"requires": {
"for-own": "1.0.0",
"is-plain-object": "2.0.4",
"kind-of": "3.2.2",
"shallow-clone": "0.1.2"
"kind-of": "6.0.2",
"shallow-clone": "1.0.0"
},
"dependencies": {
"for-own": {
@ -2108,6 +2095,11 @@
"requires": {
"for-in": "1.0.2"
}
},
"kind-of": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
"integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA=="
}
}
},
@ -3288,9 +3280,9 @@
"dev": true
},
"element-theme-chalk": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/element-theme-chalk/-/element-theme-chalk-2.1.0.tgz",
"integrity": "sha512-x6PYd6NoSdzDGtTs4sBPtohNpaOdH3YISTeEifDp8YgQd+WhtS7fzaQ2Uk86UqOMEsQIXR5IgMl7b5jhzz9CSw==",
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/element-theme-chalk/-/element-theme-chalk-2.3.2.tgz",
"integrity": "sha512-ZLZsEFK2y7wWm9zmDtYDecDW1I5klGSj5rXJlwkeUPPgnR4cLNE1IrvgzLhHNLYUqz8gDFKPYSGIMhAfIHmPEg==",
"dev": true
},
"elliptic": {
@ -7052,6 +7044,7 @@
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
"integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
"dev": true,
"requires": {
"is-buffer": "1.1.6"
}
@ -7200,7 +7193,6 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz",
"integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=",
"dev": true,
"requires": {
"big.js": "3.2.0",
"emojis-list": "2.1.0",
@ -7697,9 +7689,9 @@
}
},
"moment": {
"version": "2.21.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.21.0.tgz",
"integrity": "sha512-TCZ36BjURTeFTM/CwRcViQlfkMvL1/vFISuNLO5GkcVm1+QHfbSiNqZuWeMFjj1/3+uAjXswgRk30j1kkLYJBQ=="
"version": "2.22.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.22.0.tgz",
"integrity": "sha512-1muXCh8jb1N/gHRbn9VDUBr0GYb8A/aVcHlII9QSB68a50spqEVLIGN6KVmCOnSvJrUhC0edGgKU5ofnGXdYdg=="
},
"move-concurrently": {
"version": "1.0.1",
@ -7757,7 +7749,9 @@
"nan": {
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.8.0.tgz",
"integrity": "sha1-7XFfP+neArV6XmJS2QqWZ14fCFo="
"integrity": "sha1-7XFfP+neArV6XmJS2QqWZ14fCFo=",
"dev": true,
"optional": true
},
"nanomatch": {
"version": "1.2.9",
@ -7802,8 +7796,7 @@
"neo-async": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.5.0.tgz",
"integrity": "sha512-nJmSswG4As/MkRq7QZFuH/sf/yuv8ODdMZrY4Bedjp77a5MK4A6s7YbBB64c9u79EBUOfXUXBvArmvzTD0X+6g==",
"dev": true
"integrity": "sha512-nJmSswG4As/MkRq7QZFuH/sf/yuv8ODdMZrY4Bedjp77a5MK4A6s7YbBB64c9u79EBUOfXUXBvArmvzTD0X+6g=="
},
"nice-try": {
"version": "1.0.4",
@ -7882,9 +7875,9 @@
}
},
"node-sass": {
"version": "4.7.2",
"resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.7.2.tgz",
"integrity": "sha512-CaV+wLqZ7//Jdom5aUFCpGNoECd7BbNhjuwdsX/LkXBrHl8eb1Wjw4HvWqcFvhr5KuNgAk8i/myf/MQ1YYeroA==",
"version": "4.8.3",
"resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.8.3.tgz",
"integrity": "sha512-tfFWhUsCk/Y19zarDcPo5xpj+IW3qCfOjVdHtYeG6S1CKbQOh1zqylnQK6cV3z9k80yxAnFX9Y+a9+XysDhhfg==",
"requires": {
"async-foreach": "0.1.3",
"chalk": "1.1.3",
@ -7898,7 +7891,7 @@
"lodash.mergewith": "4.6.1",
"meow": "3.7.0",
"mkdirp": "0.5.1",
"nan": "2.8.0",
"nan": "2.10.0",
"node-gyp": "3.6.2",
"npmlog": "4.1.2",
"request": "2.79.0",
@ -7915,6 +7908,11 @@
"lru-cache": "4.1.1",
"which": "1.3.0"
}
},
"nan": {
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz",
"integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA=="
}
}
},
@ -9025,101 +9023,15 @@
}
},
"postcss-loader": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-2.1.0.tgz",
"integrity": "sha512-S/dKzpDwGFmP9g8eyCu9sUIV+/+3UooeTpYlsKf23qKDdrhHuA4pTSfytVu0rEJ0iDqUavXrgtOPq5KhNyNMOw==",
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-2.1.3.tgz",
"integrity": "sha512-RuBcNE8rjCkIB0IsbmkGFRmQJTeQJfCI88E0VTarPNTvaNSv9OFv1DvTwgtAN/qlzyiELsmmmtX/tEzKp/cdug==",
"dev": true,
"requires": {
"loader-utils": "1.1.0",
"postcss": "6.0.17",
"postcss": "6.0.21",
"postcss-load-config": "1.2.0",
"schema-utils": "0.4.3"
},
"dependencies": {
"ansi-styles": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz",
"integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==",
"dev": true,
"requires": {
"color-convert": "1.9.1"
}
},
"chalk": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz",
"integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==",
"dev": true,
"requires": {
"ansi-styles": "3.2.0",
"escape-string-regexp": "1.0.5",
"supports-color": "4.5.0"
},
"dependencies": {
"supports-color": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz",
"integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=",
"dev": true,
"requires": {
"has-flag": "2.0.0"
}
}
}
},
"has-flag": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz",
"integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=",
"dev": true
},
"loader-utils": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz",
"integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=",
"dev": true,
"requires": {
"big.js": "3.2.0",
"emojis-list": "2.1.0",
"json5": "0.5.1"
}
},
"postcss": {
"version": "6.0.17",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-6.0.17.tgz",
"integrity": "sha512-Bl1nybsSzWYbP8O4gAVD8JIjZIul9hLNOPTGBIlVmZNUnNAGL+W0cpYWzVwfImZOwumct4c1SDvSbncVWKtXUw==",
"dev": true,
"requires": {
"chalk": "2.3.0",
"source-map": "0.6.1",
"supports-color": "5.1.0"
}
},
"schema-utils": {
"version": "0.4.3",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.3.tgz",
"integrity": "sha512-sgv/iF/T4/SewJkaVpldKC4WjSkz0JsOh2eKtxCPpCO1oR05+7MOF+H476HVRbLArkgA7j5TRJJ4p2jdFkUGQQ==",
"dev": true,
"requires": {
"ajv": "5.5.2",
"ajv-keywords": "2.1.1"
}
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
},
"supports-color": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.1.0.tgz",
"integrity": "sha512-Ry0AwkoKjDpVKK4sV4h6o3UJmNRbjYm2uXhwfj3J56lMVdvnUNqzQVRztOOMGQ++w1K/TjNDFvpJk0F/LoeBCQ==",
"dev": true,
"requires": {
"has-flag": "2.0.0"
}
}
"schema-utils": "0.4.5"
}
},
"postcss-merge-idents": {
@ -10548,16 +10460,6 @@
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz",
"integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo="
},
"cliui": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz",
"integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=",
"requires": {
"string-width": "1.0.2",
"strip-ansi": "3.0.1",
"wrap-ansi": "2.1.0"
}
},
"yargs": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-7.1.0.tgz",
@ -10589,27 +10491,17 @@
}
},
"sass-loader": {
"version": "6.0.6",
"resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-6.0.6.tgz",
"integrity": "sha512-c3/Zc+iW+qqDip6kXPYLEgsAu2lf4xz0EZDplB7EmSUMda12U1sGJPetH55B/j9eu0bTtKzKlNPWWyYC7wFNyQ==",
"version": "6.0.7",
"resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-6.0.7.tgz",
"integrity": "sha512-JoiyD00Yo1o61OJsoP2s2kb19L1/Y2p3QFcCdWdF6oomBGKVYuZyqHWemRBfQ2uGYsk+CH3eCguXNfpjzlcpaA==",
"requires": {
"async": "2.6.0",
"clone-deep": "0.3.0",
"clone-deep": "2.0.2",
"loader-utils": "1.1.0",
"lodash.tail": "4.1.1",
"neo-async": "2.5.0",
"pify": "3.0.0"
},
"dependencies": {
"loader-utils": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz",
"integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=",
"requires": {
"big.js": "3.2.0",
"emojis-list": "2.1.0",
"json5": "0.5.1"
}
},
"pify": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz",
@ -10618,28 +10510,15 @@
}
},
"sass-resources-loader": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/sass-resources-loader/-/sass-resources-loader-1.3.2.tgz",
"integrity": "sha512-7U55FKFMD7I//l/Ijm3GrqjOBw66D6NbGrwiD/uZ/S85fOB/4a3kibsaRWYkbO9t1aQPZz1V/69C5k2B1nS1bw==",
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/sass-resources-loader/-/sass-resources-loader-1.3.3.tgz",
"integrity": "sha512-wEXBIn4DWE86KaYafPwoKXvyqGQdmbB7ePlGxrKTuUzwVnkgwUZXald48k+9WdwCWWffTiSr0pb9PIVGGPU/rw==",
"dev": true,
"requires": {
"async": "2.6.0",
"chalk": "1.1.3",
"glob": "7.1.2",
"loader-utils": "1.1.0"
},
"dependencies": {
"loader-utils": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz",
"integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=",
"dev": true,
"requires": {
"big.js": "3.2.0",
"emojis-list": "2.1.0",
"json5": "0.5.1"
}
}
}
},
"sax": {
@ -10834,28 +10713,19 @@
}
},
"shallow-clone": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-0.1.2.tgz",
"integrity": "sha1-WQnodLp3EG1zrEFM/sH/yofZcGA=",
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-1.0.0.tgz",
"integrity": "sha512-oeXreoKR/SyNJtRJMAKPDSvd28OqEwG4eR/xc856cRGBII7gX9lvAqDxusPm0846z/w/hWYjI1NpKwJ00NHzRA==",
"requires": {
"is-extendable": "0.1.1",
"kind-of": "2.0.1",
"lazy-cache": "0.2.7",
"kind-of": "5.1.0",
"mixin-object": "2.0.1"
},
"dependencies": {
"kind-of": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-2.0.1.tgz",
"integrity": "sha1-AY7HpM5+OobLkUG+UZ0kyPqpgbU=",
"requires": {
"is-buffer": "1.1.6"
}
},
"lazy-cache": {
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-0.2.7.tgz",
"integrity": "sha1-f+3fLctu23fRHvHRF6tf/fCrG2U="
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz",
"integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw=="
}
}
},
@ -12422,9 +12292,9 @@
}
},
"webpack": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-4.3.0.tgz",
"integrity": "sha512-oFbYLpxz8IV44Z5o2uVhvzsdw9J8x/l7Ry9EGvckkx6PFBZo5wRvd2J4nPP9oGhkl2WtNXoU4N7LM5Pjk1MAiA==",
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-4.4.1.tgz",
"integrity": "sha512-iLUJcsEAjaPKWbB32ADr29Pg9fPUVfFEMPK4VXyZGftzhSEFg2BLjHLoBYZ14wdTEA8xqG/hjpuX8qOmabRYvw==",
"dev": true,
"requires": {
"acorn": "5.5.3",

View File

@ -4,18 +4,18 @@
"author": "Eduardo <eduardo.humberto1992@gmail.com>",
"private": true,
"scripts": {
"build": "cross-env NODE_ENV=production webpack --display-error-details --mode production --progress --hide-modules"
"build": "cross-env NODE_ENV=development webpack --display-error-details --mode development --progress --hide-modules"
},
"dependencies": {
"axios": "^0.18.0",
"buefy": "^0.6.3",
"buefy": "^0.6.5",
"bulma": "^0.6.2",
"html-to-json": "^0.6.0",
"mdi": "^2.1.99",
"mdi": "^2.2.43",
"qs": "^6.5.1",
"moment": "^2.21.0",
"node-sass": "^4.7.2",
"sass-loader": "^6.0.6",
"moment": "^2.22.0",
"node-sass": "^4.8.3",
"sass-loader": "^6.0.7",
"vue": "^2.5.16",
"vue-router": "^3.0.1",
"vuedraggable": "^2.16.0",
@ -24,26 +24,26 @@
"devDependencies": {
"autoprefixer": "^8.2.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.0.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"cross-env": "^5.1.4",
"css-loader": "^0.28.11",
"cypress": "^2.1.0",
"element-theme-chalk": "^2.1.0",
"element-theme-chalk": "^2.3.2",
"eslint": "^4.19.1",
"eslint-loader": "^2.0.0",
"eslint-plugin-vue": "^4.4.0",
"file-loader": "^1.1.11",
"postcss-loader": "^2.1.0",
"sass-resources-loader": "^1.3.2",
"postcss-loader": "^2.1.3",
"sass-resources-loader": "^1.3.3",
"style-loader": "^0.20.3",
"uglifyjs-webpack-plugin": "^1.2.4",
"vue-custom-element": "^2.1.0",
"vue-loader": "^14.2.2",
"vue-template-compiler": "^2.5.16",
"webpack": "^4.3.0",
"webpack": "^4.4.1",
"webpack-cli": "^2.0.13",
"webpack-dev-server": "^3.1.1"
}

View File

@ -19,7 +19,7 @@
v-model="form.status"
:placeholder="$i18n.get('instruction_select_a_status')">
<option
id="{{'status-option-' + statusOption.value}}"
:id="`status-option-${statusOption.value}`"
v-for="statusOption in statusOptions"
:key="statusOption.value"
:value="statusOption.value"

View File

@ -0,0 +1,143 @@
<template>
<div>
<b-field
grouped
group-multiline>
<button
v-if="selectedEvents.length > 0"
class="button field is-danger"
@click="deleteSelectedEvents()"><span>{{ $i18n.get('instruction_delete_selected_events') }} </span><b-icon icon="delete"/></button>
</b-field>
<b-table
ref="eventsTable"
:data="events"
:checked-rows.sync="selectedEvents"
checkable
:loading="isLoading"
hoverable
striped
selectable
backend-sorting>
<template slot-scope="props">
<b-table-column
tabindex="0"
:label="$i18n.get('label_name')"
:aria-label="$i18n.get('label_name')"
field="props.row.title">
<router-link
class="clickable-row"
tag="span"
:to="{path: $routerHelper.getEventPath(props.row.id)}">
{{ props.row.title }}
</router-link>
</b-table-column>
<b-table-column
tabindex="0"
:aria-label="$i18n.get('label_description')"
:label="$i18n.get('label_description')"
property="description"
show-overflow-tooltip
field="props.row.description">
<router-link
class="clickable-row"
tag="span"
:to="{path: $routerHelper.getEventPath(props.row.id)}">
{{ props.row.description }}
</router-link>
</b-table-column>
<b-table-column
class="row-creation"
tabindex="0"
:aria-label="$i18n.get('label_creation') + ': ' + props.row.creation"
:label="$i18n.get('label_creation')"
property="by"
show-overflow-tooltip
field="props.row.by">
<router-link
class="clickable-row"
v-html="props.row.by"
tag="span"
:to="{path: $routerHelper.getEventPath(props.row.id)}"/>
</b-table-column>
<b-table-column
tabindex="0"
:label="$i18n.get('label_actions')"
width="78"
:aria-label="$i18n.get('label_actions')">
<a
id="button-approve"
:aria-label="$i18n.getFrom('events','approve_item')"
@click.prevent.stop="approve(props.row.id)">
<b-icon
type="is-gray"
icon="check"/>
</a>
<a
id="button-not-approve"
:aria-label="$i18n.getFrom('events','not_approve_item')"
@click.prevent.stop="notApprove(props.row.id)">
<b-icon
type="is-gray"
icon="block"/>
</a>
</b-table-column>
</template>
</b-table>
</div>
</template>
<script>
import { mapActions } from 'vuex'
export default {
name: 'EventsList',
data(){
return {
selectedEvents: []
}
},
props: {
isLoading: false,
totalEvents: 0,
page: 1,
eventsPerPage: 12,
events: Array
},
methods: {
...mapActions('events', [
'approve',
'notApprove'
])
}
}
</script>
<style lang="scss" scoped>
@import "../../scss/_variables.scss";
.table-thumb {
max-height: 38px !important;
vertical-align: middle !important;
}
.row-creation span {
color: $gray-light;
font-size: 0.75em;
line-height: 1.5
}
.clickable-row{ cursor: pointer !important; }
</style>

View File

@ -1,23 +1,195 @@
<template>
<div class="page-container">
<div class="primary-page">
<h1>Events (or Activies) Page</h1>
<div>
<div class="primary-page page-container-small">
<div class="columns above-subheader">
<div class="column table-container">
<events-list
:is-loading="isLoading"
:total-events="totalEvents"
:page="page"
:events-per-page="eventsPerPage"
:events="events"/>
<!-- Footer -->
<div
class="table-footer"
v-if="totalEvents > 0">
<div class="shown-items">
{{
$i18n.get('info_showing_events') +
(eventsPerPage * (page - 1) + 1) +
$i18n.get('info_to') +
getLastEventNumber() +
$i18n.get('info_of') + totalEvents + '.'
}}
</div>
<div class="items-per-page">
<b-field
horizontal
:label="$i18n.get('label_events_per_page')">
<b-select
:value="eventsPerPage"
@input="onChangeEventsPerPage"
:disabled="events.length <= 0">
<option value="12">12</option>
<option value="24">24</option>
<option value="48">48</option>
<option value="96">96</option>
</b-select>
</b-field>
</div>
<div class="pagination">
<b-pagination
@change="onPageChange"
:total="totalEvents"
:current.sync="page"
order="is-centered"
size="is-small"
:per-page="eventsPerPage"/>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'EventsPage',
data(){
return {
import EventsList from "../../components/lists/events-list.vue";
import { mapActions, mapGetters } from 'vuex';
import moment from 'moment'
export default {
name: 'EventsPage',
data(){
return {
isLoading: false,
totalEvents: 0,
page: 1,
eventsPerPage: 12
}
},
components: {
EventsList
},
methods: {
...mapActions('events', [
'fetchEvents',
]),
...mapGetters('events', [
'getEvents'
]),
onChangeEventsPerPage(value) {
let prevValue = this.eventsPerPage;
this.eventsPerPage = value;
this.$userPrefs.set('events_per_page', value, prevValue);
this.loadEvents();
},
onPageChange(page) {
this.page = page;
this.loadEvents();
},
loadEvents() {
this.isLoading = true;
this.fetchEvents({ 'page': this.page, 'eventsPerPage': this.eventsPerPage })
.then((res) => {
this.isLoading = false;
this.totalEvents = res.total;
})
.catch(() => {
this.isLoading = false;
});
},
getLastEventNumber() {
let last = (Number(this.eventsPerPage * (this.page - 1)) + Number(this.eventsPerPage));
return last > this.totalEvents ? this.totalEvents : last;
}
},
computed: {
events(){
let eventsList = this.getEvents();
for (let event of eventsList)
event['by'] = this.$i18n.get('info_by') +
event['user_name'] + '<br>' + this.$i18n.get('info_date') +
moment(event['log_date'], 'YYYY-MM-DD').format('DD/MM/YYYY');
return eventsList;
}
},
created() {
this.$userPrefs.get('events_per_page')
.then((value) => {
this.eventsPerPage = value;
})
.catch(() => {
this.$userPrefs.set('events_per_page', 12, null);
});
},
mounted(){
this.loadEvents();
}
}
}
</script>
<style scoped>
<style lang="scss" scoped>
@import '../../scss/_variables.scss';
.sub-header {
max-height: $header-height;
height: $header-height;
margin-left: -$page-small-side-padding;
margin-right: -$page-small-side-padding;
margin-top: -$page-small-top-padding;
padding-top: $page-small-top-padding;
padding-left: $page-small-side-padding;
padding-right: $page-small-side-padding;
border-bottom: 0.5px solid #ddd;
.header-item {
display: inline-block;
padding-right: 8em;
}
@media screen and (max-width: 769px) {
height: 60px;
margin-top: -0.5em;
padding-top: 0.9em;
.header-item {
padding-right: 0.5em;
}
}
}
.above-subheader {
margin-bottom: 0;
margin-top: 0;
min-height: 100%;
height: auto;
.filters-menu {
min-width: $side-menu-width;
max-width: $side-menu-width;
background-color: $primary-lighter;
margin-left: -$page-small-side-padding;
padding-left: $page-small-side-padding
}
.table-container {
margin-right: -$page-small-side-padding;
padding: 3em 2.5em;
}
@media screen and (max-width: 769px) {
.filters-menu {
display: none;
}
.table-container {
margin-right: 0;
padding: .85em 0em;
}
}
}
</style>

View File

@ -9,13 +9,15 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
*/
class Log extends Entity {
protected
$title,
$order,
$parent,
$decription,
$blog_id,
$user_id;
protected
$title,
$order,
$parent,
$description,
$blog_id,
$user_id,
$log_date,
$user_name;
protected static $post_type = 'tainacan-log';
/**
@ -24,219 +26,261 @@ class Log extends Entity {
* @var string
*/
protected $repository = 'Logs';
public function __construct($which=0) {
parent::__construct($which);
if( is_int($which) && $which == 0) {
public function __construct( $which = 0 ) {
parent::__construct( $which );
if ( is_int( $which ) && $which == 0 ) {
$this->set_user_id();
$this->set_blog_id();
}
}
public function __toString(){
return 'Hello, my title is '. $this->get_title();
public function __toString() {
return 'Hello, my title is ' . $this->get_title();
}
/**
* Return the Log title
*
* @return string
*/
function get_title() {
return $this->get_mapped_property('title');
}
/**
* @return array
*/
public function __toArray() {
$array_log = parent::__toArray();
/**
* Return the log order type
*
* @return string
*/
function get_order() {
return $this->get_mapped_property('order');
}
$array_log['user_name'] = $this->get_user_name();
/**
* Retun the parent ID
*
* @return integer
*/
function get_parent() {
return $this->get_mapped_property('parent');
}
return $array_log;
}
/**
* Return the Log description
*
* @return string
*/
function get_description() {
return $this->get_mapped_property('description');
}
/**
* Return the ID of blog
*
* @return integer
*/
function get_blog_id() {
return $this->get_mapped_property('blog_id');
}
/**
* Return User Id of who make the action
*
* @return int User Id of logged action
*/
function get_user_id() {
return $this->get_mapped_property('user_id');
}
/**
* Get value of log entry
*
* @param mixed $value
* @return void
*/
public function get_value() {
return maybe_unserialize( base64_decode($this->get_mapped_property('value')));
}
/**
* Get old value of log entry object
*
* @param mixed $value
* @return void
*/
public function get_old_value() {
return maybe_unserialize( base64_decode($this->get_mapped_property('old_value')));
}
/**
* Set log tittle
*
* @param string $value
* @return void
*/
function set_title($value) {
$this->set_mapped_property('title', $value);
}
/**
* Return the Log title
*
* @return string
*/
function get_title() {
return $this->get_mapped_property( 'title' );
}
/**
* Define the order type
*
* @param [string] $value
* @return void
*/
function set_order($value) {
$this->set_mapped_property('order', $value);
}
/**
* @return string
*/
function get_user_name() {
return get_the_author_meta( 'display_name', $this->get_user_id() );
}
/**
* Define the parent ID
*
* @param [integer] $value
* @return void
*/
function set_parent($value) {
$this->set_mapped_property('parent', $value);
}
/**
* Return the log date
*
* @return mixed|null
*/
function get_log_date() {
return $this->get_mapped_property( 'log_date' );
}
/**
* Define the Log description
*
* @param [string] $value
* @return void
*/
function set_description($value) {
$this->set_mapped_property('description', $value);
}
/**
* Return the log order type
*
* @return string
*/
function get_order() {
return $this->get_mapped_property( 'order' );
}
/**
* Define the user ID of log entry
*
* @param [integer] $value
* @return void
*/
protected function set_user_id($value = 0) {
if(0 == $value) $value = get_current_user_id();
$this->set_mapped_property('user_id', $value);
}
/**
* Define the blog ID of log entry
*
* @param [integer] $value
* @return void
*/
protected function set_blog_id($value = 0) {
if(0 == $value) $value = get_current_blog_id();
$this->set_mapped_property('blog_id', $value);
}
/**
* Define the value of log entry
*
* @param [mixed] $value
* @return void
*/
protected function set_value($value = null) {
$this->set_mapped_property('value', base64_encode( maybe_serialize($value)));
}
/**
* Set old value of log entry
*
* @param [mixed] $value
* @return void
*/
protected function set_old_value($value = null) {
$this->set_mapped_property('old_value', base64_encode( maybe_serialize($value)));
}
/**
*
* @param boolean|string $msn
* @param string $desc
* @param mixed $new_value
* @param mixed $old_value
* @param string $status 'publish', 'private' or 'pending'
* @throws \Exception
* @return \Tainacan\Entities\Log
*/
public static function create($msn = false, $desc = '', $new_value = null, $old_value = null, $status = 'publish') {
$log = new Log();
$log->set_title($msn);
$log->set_description($desc);
$log->set_status($status);
if(!is_null($new_value)) {
$type = gettype($new_value);
$log->set_value($new_value);
if(!is_null($old_value)) $log->set_old_value($old_value);
}
elseif($msn === false) {
throw new \Exception('msn or new_value is need to log');
/**
* Retun the parent ID
*
* @return integer
*/
function get_parent() {
return $this->get_mapped_property( 'parent' );
}
/**
* Return the Log description
*
* @return string
*/
function get_description() {
return $this->get_mapped_property( 'description' );
}
/**
* Return the ID of blog
*
* @return integer
*/
function get_blog_id() {
return $this->get_mapped_property( 'blog_id' );
}
/**
* Return User Id of who make the action
*
* @return int User Id of logged action
*/
function get_user_id() {
return $this->get_mapped_property( 'user_id' );
}
/**
* Get value of log entry
*
* @param mixed $value
*
* @return void
*/
public function get_value() {
return maybe_unserialize( base64_decode( $this->get_mapped_property( 'value' ) ) );
}
/**
* Get old value of log entry object
*
* @param mixed $value
*
* @return void
*/
public function get_old_value() {
return maybe_unserialize( base64_decode( $this->get_mapped_property( 'old_value' ) ) );
}
/**
* Set log tittle
*
* @param string $value
*
* @return void
*/
function set_title( $value ) {
$this->set_mapped_property( 'title', $value );
}
/**
* Define the order type
*
* @param [string] $value
*
* @return void
*/
function set_order( $value ) {
$this->set_mapped_property( 'order', $value );
}
/**
* Define the parent ID
*
* @param [integer] $value
*
* @return void
*/
function set_parent( $value ) {
$this->set_mapped_property( 'parent', $value );
}
/**
* Define the Log description
*
* @param [string] $value
*
* @return void
*/
function set_description( $value ) {
$this->set_mapped_property( 'description', $value );
}
/**
* Define the user ID of log entry
*
* @param [integer] $value
*
* @return void
*/
protected function set_user_id( $value = 0 ) {
if ( 0 == $value ) {
$value = get_current_user_id();
}
$this->set_mapped_property( 'user_id', $value );
}
/**
* Define the blog ID of log entry
*
* @param [integer] $value
*
* @return void
*/
protected function set_blog_id( $value = 0 ) {
if ( 0 == $value ) {
$value = get_current_blog_id();
}
$this->set_mapped_property( 'blog_id', $value );
}
/**
* Define the value of log entry
*
* @param [mixed] $value
*
* @return void
*/
protected function set_value( $value = null ) {
$this->set_mapped_property( 'value', base64_encode( maybe_serialize( $value ) ) );
}
/**
* Set old value of log entry
*
* @param [mixed] $value
*
* @return void
*/
protected function set_old_value( $value = null ) {
$this->set_mapped_property( 'old_value', base64_encode( maybe_serialize( $value ) ) );
}
/**
*
* @param boolean|string $msn
* @param string $desc
* @param mixed $new_value
* @param mixed $old_value
* @param string $status 'publish', 'private' or 'pending'
*
* @throws \Exception
* @return \Tainacan\Entities\Log
*/
public static function create( $msn = false, $desc = '', $new_value = null, $old_value = null, $status = 'publish' ) {
$log = new Log();
$log->set_title( $msn );
$log->set_description( $desc );
$log->set_status( $status );
if ( ! is_null( $new_value ) ) {
$log->set_value( $new_value );
if ( ! is_null( $old_value ) ) {
$log->set_old_value( $old_value );
}
} elseif ( $msn === false ) {
throw new \Exception( 'msn or new_value is need to log' );
}
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
if ($log->validate()) {
return $Tainacan_Logs->insert($log);
} else {
throw new \Exception('Invalid log');
}
}
/**
* {@inheritDoc}
* @see \Tainacan\Repositories\Logs::approve
*/
public function approve() {
$repository = $this->get_repository();
if ( $log->validate() ) {
return $Tainacan_Logs->insert( $log );
} else {
throw new \Exception( 'Invalid log' );
}
return $repository->approve($this);
}
}
/**
* {@inheritDoc}
* @see \Tainacan\Repositories\Logs::approve
*/
public function approve() {
$repository = $this->get_repository();
return $repository->approve( $this );
}
}

View File

@ -1,5 +1,7 @@
<?php
namespace Tainacan\Repositories;
use Tainacan\Entities;
use Tainacan\Entities\Entity;
@ -7,247 +9,258 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/**
* Implement a Logs system
*
*
* @author medialab
*
*/
class Logs extends Repository {
public $entities_type = '\Tainacan\Entities\Log';
private static $instance = null;
private static $instance = null;
public static function getInstance()
{
if(!isset(self::$instance))
{
self::$instance = new self();
}
public static function getInstance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
return self::$instance;
}
protected function __construct() {
parent::__construct();
add_action('tainacan-insert', array($this, 'log_inserts'));
add_action( 'tainacan-insert', array( $this, 'log_inserts' ) );
}
public function get_map() {
return apply_filters( 'tainacan-get-map-' . $this->get_name(), [
'title' => [
'map' => 'post_title',
'title' => __( 'Title', 'tainacan' ),
'type' => 'string',
'description' => __( 'The title of the log', 'tainacan' ),
'on_error' => __( 'The title should be a text value and not empty', 'tainacan' ),
'validation' => ''
],
'log_date' => [
'map' => 'post_date',
'title' => __( 'Log date', 'tainacan' ),
'type' => 'string',
'description' => __( 'The log date', 'tainacan' ),
],
'order' => [
'map' => 'menu_order',
'title' => __( 'Menu order', 'tainacan' ),
'type' => 'string',
'description' => __( 'Log order' ),
'validation' => ''
],
'parent' => [
'map' => 'parent',
'title' => __( 'Parent', 'tainacan' ),
'type' => 'string',
'description' => __( 'Log order' ),
'validation' => ''
],
'description' => [
'map' => 'post_content',
'title' => __( 'Description', 'tainacan' ),
'type' => 'string',
'description' => __( 'The log description' ),
'default' => '',
'validation' => ''
],
'slug' => [
'map' => 'post_name',
'title' => __( 'Slug', 'tainacan' ),
'type' => 'string',
'description' => __( 'The log slug' ),
'validation' => ''
],
'itens_per_page' => [
'map' => 'meta',
'title' => __( 'Itens per page', 'tainacan' ),
'type' => 'integer',
'description' => __( 'The quantity of items that should be load' ),
'validation' => ''
],
'user_id' => [
'map' => 'post_author',
'title' => __( 'User ID', 'tainacan' ),
'type' => 'integer',
'description' => __( 'Unique identifier' ),
'validation' => ''
],
'blog_id' => [
'map' => 'meta',
'title' => __( 'Blog ID', 'tainacan' ),
'type' => 'integer',
'description' => __( 'Unique identifier' ),
'validation' => ''
],
'value' => [
'map' => 'meta',
'title' => __( 'Actual value', 'tainacan' ),
'type' => 'string',
'description' => __( 'The actual log value' ),
'validation' => ''
],
'old_value' => [
'map' => 'meta',
'title' => __( 'Old value', 'tainacan' ),
'type' => 'string',
'description' => __( 'The old log value' ),
'validation' => ''
],
] );
}
/**
*
* {@inheritDoc}
* @see \Tainacan\Repositories\Repository::register_post_type()
*/
public function register_post_type() {
$labels = array(
'name' => __( 'Logs', 'tainacan' ),
'singular_name' => __( 'Log', 'tainacan' ),
'add_new' => __( 'Add new', 'tainacan' ),
'add_new_item' => __( 'Add new Log', 'tainacan' ),
'edit_item' => __( 'Edit Log', 'tainacan' ),
'new_item' => __( 'New Log', 'tainacan' ),
'view_item' => __( 'View Log', 'tainacan' ),
'search_items' => __( 'Search Logs', 'tainacan' ),
'not_found' => __( 'No Logs found ', 'tainacan' ),
'not_found_in_trash' => __( 'No Logs found in trash', 'tainacan' ),
'parent_item_colon' => __( 'Parent Log:', 'tainacan' ),
'menu_name' => __( 'Logs', 'tainacan' )
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
//'supports' => array('title'),
//'taxonomies' => array(self::TAXONOMY),
'public' => false,
'show_ui' => tnc_enable_dev_wp_interface(),
'show_in_menu' => tnc_enable_dev_wp_interface(),
//'menu_position' => 5,
//'show_in_nav_menus' => false,
'publicly_queryable' => false,
'exclude_from_search' => true,
'has_archive' => false,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'map_meta_cap' => true,
'capability_type' => Entities\Log::get_capability_type(),
'supports' => [
'title',
'editor',
'thumbnail',
]
);
register_post_type( Entities\Log::get_post_type(), $args );
}
public function get_map() {
return apply_filters('tainacan-get-map-'.$this->get_name(), [
'title' => [
'map' => 'post_title',
'title' => __('Title', 'tainacan'),
'type' => 'string',
'description' => __('The title of the log'),
'on_error' => __('The title should be a text value and not empty', 'tainacan'),
'validation' => ''
],
'order' => [
'map' => 'menu_order',
'title' => __('Menu order', 'tainacan'),
'type' => 'string',
'description' => __('Log order'),
'validation' => ''
],
'parent' => [
'map' => 'parent',
'title' => __('Parent', 'tainacan'),
'type' => 'string',
'description' => __('Log order'),
'validation' => ''
],
'description' => [
'map' => 'post_content',
'title' => __('Description', 'tainacan'),
'type' => 'string',
'description' => __('The log description'),
'default' => '',
'validation' => ''
],
'slug' => [
'map' => 'post_name',
'title' => __('Slug', 'tainacan'),
'type' => 'string',
'description' => __('The log slug'),
'validation' => ''
],
'itens_per_page' => [
'map' => 'meta',
'title' => __('Itens per page', 'tainacan'),
'type' => 'integer',
'description' => __('The quantity of items that should be load'),
'validation' => ''
],
'user_id' => [
'map' => 'post_author',
'title' => __('User ID', 'tainacan'),
'type' => 'integer',
'description' => __('Unique identifier'),
'validation' => ''
],
'blog_id' => [
'map' => 'meta',
'title' => __('Blog ID', 'tainacan'),
'type' => 'integer',
'description' => __('Unique identifier'),
'validation' => ''
],
'value' => [
'map' => 'meta',
'title' => __('Actual value', 'tainacan'),
'type' => 'string',
'description' => __('The actual log value'),
'validation' => ''
],
'old_value' => [
'map' => 'meta',
'title' => __('Old value', 'tainacan'),
'type' => 'string',
'description' => __('The old log value'),
'validation' => ''
],
]);
}
/**
*
* {@inheritDoc}
* @see \Tainacan\Repositories\Repository::register_post_type()
*/
public function register_post_type() {
$labels = array(
'name' => __('Logs', 'tainacan'),
'singular_name' => __('Log', 'tainacan'),
'add_new' => __('Add new', 'tainacan'),
'add_new_item' => __('Add new Log', 'tainacan'),
'edit_item' => __('Edit Log', 'tainacan'),
'new_item' => __('New Log', 'tainacan'),
'view_item' => __('View Log', 'tainacan'),
'search_items' => __('Search Logs', 'tainacan'),
'not_found' => __('No Logs found ', 'tainacan'),
'not_found_in_trash' => __('No Logs found in trash', 'tainacan'),
'parent_item_colon' => __('Parent Log:', 'tainacan'),
'menu_name' => __('Logs', 'tainacan')
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
//'supports' => array('title'),
//'taxonomies' => array(self::TAXONOMY),
'public' => false,
'show_ui' => tnc_enable_dev_wp_interface(),
'show_in_menu' => tnc_enable_dev_wp_interface(),
//'menu_position' => 5,
//'show_in_nav_menus' => false,
'publicly_queryable' => false,
'exclude_from_search' => true,
'has_archive' => false,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'map_meta_cap' => true,
'capability_type' => Entities\Log::get_capability_type(),
'supports' => [
'title',
'editor',
'thumbnail',
]
);
register_post_type(Entities\Log::get_post_type(), $args);
}
/**
* fetch logs based on ID or WP_Query args
*
* Logs are stored as posts. Check WP_Query docs
* to learn all args accepted in the $args parameter (@see https://developer.wordpress.org/reference/classes/wp_query/)
* You can also use a mapped property, such as name and description, as an argument and it will be mapped to the
* appropriate WP_Query argument
*
* @param array $args WP_Query args || int $args the log id
* @param string $output The desired output format (@see \Tainacan\Repositories\Repository::fetch_output() for possible values)
* @return \WP_Query|Array an instance of wp query OR array of entities;
*/
public function fetch($args = [], $output = null){
if(is_numeric($args)){
$existing_post = get_post($args);
if ($existing_post instanceof \WP_Post) {
return new Entities\Log($existing_post);
} else {
return [];
}
} elseif (is_array($args)) {
$args = array_merge([
'post_status' => 'publish',
], $args);
/**
* fetch logs based on ID or WP_Query args
*
* Logs are stored as posts. Check WP_Query docs
* to learn all args accepted in the $args parameter (@see https://developer.wordpress.org/reference/classes/wp_query/)
* You can also use a mapped property, such as name and description, as an argument and it will be mapped to the
* appropriate WP_Query argument
*
* @param array $args WP_Query args || int $args the log id
* @param string $output The desired output format (@see \Tainacan\Repositories\Repository::fetch_output() for possible values)
*
* @return \WP_Query|Array an instance of wp query OR array of entities;
*/
public function fetch( $args = [], $output = null ) {
if ( is_numeric( $args ) ) {
$existing_post = get_post( $args );
if ( $existing_post instanceof \WP_Post ) {
return new Entities\Log( $existing_post );
} else {
return [];
}
$args = $this->parse_fetch_args($args);
} elseif ( is_array( $args ) ) {
$args = array_merge( [
'posts_per_page' => 1,
], $args );
$args['post_type'] = Entities\Log::get_post_type();
$args = $this->parse_fetch_args( $args );
$wp_query = new \WP_Query($args);
return $this->fetch_output($wp_query, $output);
}
}
$args['post_type'] = Entities\Log::get_post_type();
public function delete($object){
$wp_query = new \WP_Query( $args );
}
return $this->fetch_output( $wp_query, $output );
}
}
public function update($object, $new_values = null){
public function delete( $object ) {
}
public function fetch_last() {
$args = [
'post_type' => Entities\Log::get_post_type(),
'posts_per_page' => 1,
'post_status' => 'publish',
];
$logs = $this->fetch($args, 'OBJECT');
}
return array_pop($logs);
}
/**
* Insert a log when a new entity is inserted
* @param Entity $new_value
* @param Entity $value
*
* @return Entities\Log new created log
*/
public function log_inserts($new_value, $value = null) {
$msn = "";
if(is_object($new_value)) {
// do not log a log
if(method_exists($new_value, 'get_post_type') && $new_value->get_post_type() == 'tainacan-log'){
return;
}
$type = get_class($new_value);
$msn = sprintf( esc_html__( 'a %s has been created/updated.', 'tainacan' ), $type );
}
public function update( $object, $new_values = null ) {
$msn = apply_filters('tainacan-insert-log-message-title', $msn, $type, $new_value);
return Entities\Log::create($msn, 'empty', $new_value, $value);
}
/**
*
* @param Entities\Log $log
* @return Entities\Entity|boolean return insert/update valeu or false
*/
public function approve($log) {
$log = self::get_entity_by_post($log);
if($log->get_status() == 'pending') {
/** @var Entity $value **/
$value = $log->get_value();
//$value->set_status('publish'); // TODO check if publish the entity on approve
$repository = self::get_repository($value);
return $repository->insert($value);
}
return false;
}
}
public function fetch_last() {
$args = [
'post_type' => Entities\Log::get_post_type(),
'posts_per_page' => 1,
];
$logs = $this->fetch( $args, 'OBJECT' );
return array_pop( $logs );
}
/**
* Insert a log when a new entity is inserted
*
* @param Entity $new_value
* @param Entity $value
*
* @return Entities\Log new created log
*/
public function log_inserts( $new_value, $value = null ) {
$msn = "";
if ( is_object( $new_value ) ) {
// do not log a log
if ( method_exists( $new_value, 'get_post_type' ) && $new_value->get_post_type() == 'tainacan-log' ) {
return;
}
$type = get_class( $new_value );
$msn = sprintf( esc_html__( 'a %s has been created/updated.', 'tainacan' ), $type );
}
$msn = apply_filters( 'tainacan-insert-log-message-title', $msn, $type, $new_value );
return Entities\Log::create( $msn, '', $new_value, $value );
}
/**
*
* @param Entities\Log $log
*
* @return Entities\Entity|boolean return insert/update valeu or false
* @throws \Exception
*/
public function approve( $log ) {
$log = self::get_entity_by_post( $log );
if ( $log->get_status() == 'pending' ) {
/** @var Entity $value * */
$value = $log->get_value();
//$value->set_status('publish'); // TODO check if publish the entity on approve
$repository = self::get_repository( $value );
return $repository->insert( $value );
}
return false;
}
}

View File

@ -0,0 +1,29 @@
import axios from '../../../axios/axios'
export const fetchEvents = ({ commit }, { page, eventsPerPage } ) => {
return new Promise((resolve, reject) => {
axios.tainacan.get(`/logs?paged=${page}&perpage=${eventsPerPage}`)
.then(res => {
let events = res.data;
commit('setEvents', events);
resolve({
'events': events,
'total': res.headers['x-wp-total']
});
})
.catch(error => {
reject(error);
});
});
};
export const approve = ({commit}, eventId) => {
};
export const notApprove = ({commit}, eventId) => {
};

View File

@ -0,0 +1,11 @@
export const getEvents = state => {
return state.events;
};
export const getEvent = state => {
return state.event;
};
export const getEventName = state => {
return state.eventName;
};

View File

@ -0,0 +1,17 @@
import * as actions from './actions';
import * as getters from './getters';
import * as mutations from './mutations';
const state = {
events: [],
event: {},
eventName: String,
};
export default {
namespaced: true,
state,
mutations,
actions,
getters
}

View File

@ -0,0 +1,3 @@
export const setEvents = (state, events) => {
state.events = events;
};

View File

@ -6,7 +6,8 @@ import collection from './modules/collection/';
import fields from './modules/fields/';
import filter from './modules/filter/';
import search from './modules/search/';
import category from './modules/category/'
import category from './modules/category/';
import events from './modules/events';
Vue.use(Vuex);
@ -18,5 +19,6 @@ export default new Vuex.Store({
filter,
search,
category,
events,
}
})

View File

@ -62,7 +62,7 @@ module.exports = {
},
};
// Change to false for development mode
// Change to true for production mode
const production = false;
if (production === true) {
@ -70,6 +70,8 @@ if (production === true) {
console.log({'production': production});
module.exports.mode = 'production';
module.exports.devtool = '';
module.exports.plugins = (module.exports.plugins || []).concat([
@ -105,8 +107,6 @@ if (production === true) {
}),
];
module.exports.mode = 'development';
module.exports.resolve = {
alias: {
//'vue$': 'vue/dist/vue.esm' // uncomment this and comment the above to use vue dev tools (can cause type error)