From d61818761e4284aac02a1fbc7e0170dbbf35b524 Mon Sep 17 00:00:00 2001 From: Murod Khaydarov Date: Sat, 19 Jan 2019 17:09:11 +0300 Subject: [PATCH] Order child pages (#21) * save ordering pages * move to another collection * requested changes. Code improvements * add margin * unit tests * fix * requested changes * recursive method: create menu tree * update comments * fix bug * requested changes * move const * fix error message on catch * add migration * rewrite to splices * move methods * testing put above method * linter fix --- package.json | 3 + public/dist/code-styling.bundle.js | 2 +- public/dist/editor.bundle.js | 2161 +------------------ public/dist/main.bundle.js | 4 +- public/dist/main.css | 2 +- src/controllers/pages.js | 1 - src/controllers/pagesOrder.js | 95 + src/frontend/js/modules/writing.js | 11 +- src/frontend/styles/components/writing.pcss | 4 + src/models/page.js | 1 - src/models/pageOrder.js | 156 ++ src/routes/api/pages.js | 17 +- src/routes/middlewares/pages.js | 55 +- src/routes/pages.js | 11 +- src/utils/database/index.js | 4 +- src/utils/database/pagesOrder.js | 34 + src/views/pages/form.twig | 26 +- test/models/pageOrder.js | 143 ++ test/rest/pages.js | 21 +- yarn.lock | 881 ++++---- 20 files changed, 1069 insertions(+), 2563 deletions(-) create mode 100644 src/controllers/pagesOrder.js create mode 100644 src/models/pageOrder.js create mode 100644 src/utils/database/pagesOrder.js create mode 100644 test/models/pageOrder.js diff --git a/package.json b/package.json index c7f7e9e..5c83380 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "codex.editor.header": "^2.0.5", "cookie-parser": "~1.4.3", "debug": "~4.1.0", + "eslint-plugin-standard": "^4.0.0", "express": "~4.16.0", "http-errors": "~1.7.1", "module-dispatcher": "^1.0.2", @@ -48,6 +49,8 @@ "eslint": "^5.3.0", "eslint-config-codex": "github:codex-team/eslint-config", "eslint-plugin-chai-friendly": "^0.4.1", + "eslint-plugin-import": "^2.14.0", + "eslint-plugin-node": "^8.0.1", "highlight.js": "^9.13.1", "husky": "^1.1.2", "mini-css-extract-plugin": "^0.4.3", diff --git a/public/dist/code-styling.bundle.js b/public/dist/code-styling.bundle.js index c20d36c..42d32e8 100644 --- a/public/dist/code-styling.bundle.js +++ b/public/dist/code-styling.bundle.js @@ -1 +1 @@ -(window.webpackJsonpDocs=window.webpackJsonpDocs||[]).push([[2],Array(50).concat([function(e,n){e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,n,t){var r=t(56),a=t(50);e.exports=function(e){return r(a(e))}},function(e,n,t){var r=t(30)("keys"),a=t(18);e.exports=function(e){return r[e]||(r[e]=a(e))}},function(e,n,t){var r=t(50);e.exports=function(e){return Object(r(e))}},function(e,n,t){"use strict";var r=t(19),a=t(12),i=t(14),o=t(11),s=t(13),c=t(66),u=t(29),l=t(72),f=t(1)("iterator"),g=!([].keys&&"next"in[].keys()),d=function(){return this};e.exports=function(e,n,t,p,v,E,h){c(t,n,p);var b,m,y,_=function(e){if(!g&&e in O)return O[e];switch(e){case"keys":case"values":return function(){return new t(this,e)}}return function(){return new t(this,e)}},R=n+" Iterator",w="values"==v,N=!1,O=e.prototype,x=O[f]||O["@@iterator"]||v&&O[v],M=x||_(v),S=v?w?_("entries"):M:void 0,A="Array"==n&&O.entries||x;if(A&&(y=l(A.call(new e)))!==Object.prototype&&y.next&&(u(y,R,!0),r||"function"==typeof y[f]||o(y,f,d)),w&&x&&"values"!==x.name&&(N=!0,M=function(){return x.call(this)}),r&&!h||!g&&!N&&O[f]||o(O,f,M),s[n]=M,s[R]=d,v)if(b={values:w?M:_("values"),keys:E?M:_("keys"),entries:S},h)for(m in b)m in O||i(O,m,b[m]);else a(a.P+a.F*(g||N),n,b);return b}},function(e,n,t){var r=t(69),a=t(57);e.exports=Object.keys||function(e){return r(e,a)}},function(e,n,t){var r=t(10);e.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==r(e)?e.split(""):Object(e)}},function(e,n){e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},,,,,,,function(e,n,t){"use strict";var r=t(65)(!0);t(54)(String,"String",function(e){this._t=String(e),this._i=0},function(){var e,n=this._t,t=this._i;return t>=n.length?{value:void 0,done:!0}:(e=r(n,t),this._i+=e.length,{value:e,done:!1})})},function(e,n,t){var r=t(28),a=t(50);e.exports=function(e){return function(n,t){var i,o,s=String(a(n)),c=r(t),u=s.length;return c<0||c>=u?e?"":void 0:(i=s.charCodeAt(c))<55296||i>56319||c+1===u||(o=s.charCodeAt(c+1))<56320||o>57343?e?s.charAt(c):i:e?s.slice(c,c+2):o-56320+(i-55296<<10)+65536}}},function(e,n,t){"use strict";var r=t(67),a=t(27),i=t(29),o={};t(11)(o,t(1)("iterator"),function(){return this}),e.exports=function(e,n,t){e.prototype=r(o,{next:a(1,t)}),i(e,n+" Iterator")}},function(e,n,t){var r=t(2),a=t(68),i=t(57),o=t(52)("IE_PROTO"),s=function(){},c=function(){var e,n=t(17)("iframe"),r=i.length;for(n.style.display="none",t(34).appendChild(n),n.src="javascript:",(e=n.contentWindow.document).open(),e.write("