From b9d2a81b984c76c792d70359187bff294062b2ec Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 7 May 2018 22:47:41 +0100 Subject: [PATCH] save tabs --- src/vue-poc/app.vue | 11 +- src/vue-poc/components/filters.js | 6 +- src/vue-poc/core.js | 37 +- src/vue-poc/data/vue-poc/history.xml | 2 +- src/vue-poc/expath-pkg.xml | 7 +- src/vue-poc/features/collection/files.vue | 13 +- src/vue-poc/features/edit/tabs.vue | 35 +- .../features/form/form-json-schema.vue | 2 +- .../images/tasks/pics-01-store-directory.xq | 2 +- src/vue-poc/features/svg2.vue | 85 +- src/vue-poc/features/tree2.vue | 9 +- src/vue-poc/static/app-gen.js | 194 +- src/vue-poc/static/app.css | 8 +- src/vue-poc/static/app.html | 22 +- src/vue-poc/static/resources/hierarchy.json | 3576 +++++++++++++++++ .../static/resources/svg/PhoneticsGuide.svg | 601 +++ .../static/resources/{ => svg}/butterfly.svg | 0 .../https _shkspr.mobi_svg_calendar.svg | 0 src/vue-poc/static/resources/svg/tiger.svg | 726 ++++ src/vue-poc/static/serviceworker.js | 5 +- src/vue-poc/static/svg/d3-svg.css | 1 - src/vue-poc/static/svg/d3-svg.js | 13 +- 22 files changed, 5221 insertions(+), 134 deletions(-) create mode 100644 src/vue-poc/static/resources/hierarchy.json create mode 100644 src/vue-poc/static/resources/svg/PhoneticsGuide.svg rename src/vue-poc/static/resources/{ => svg}/butterfly.svg (100%) rename src/vue-poc/static/resources/{ => svg}/https _shkspr.mobi_svg_calendar.svg (100%) create mode 100644 src/vue-poc/static/resources/svg/tiger.svg diff --git a/src/vue-poc/app.vue b/src/vue-poc/app.vue index 5655f06..f751db2 100644 --- a/src/vue-poc/app.vue +++ b/src/vue-poc/app.vue @@ -190,6 +190,7 @@ {href: '/select',text: 'Select',icon: 'extension'}, {href: '/puzzle',text: 'Puzzle',icon: 'extension'}, {href: '/svg',text: 'SVG',icon: 'extension'}, + {href: '/svg2',text: 'SVG2',icon: 'extension'}, {href: '/tree',text: 'Tree',icon: 'nature'}, {href: '/tree2',text: 'Tree 2',icon: 'nature'} ]}, @@ -228,9 +229,15 @@ }, created(){ - console.log("create-----------") + console.log("create-----------"); + var that=this - this.$on("theme",this.onDark) + this.$on("theme",this.onDark); + window.addEventListener('error', function (err) { + var msg=JSON.stringify(err) + that.showAlert("vue error:\n"+msg); + //alert('window.onerrora-\n' + err.message); + }); Vue.config.errorHandler = function (err, vm, info) { // handle error // `info` is a Vue-specific error info, e.g. which lifecycle hook diff --git a/src/vue-poc/components/filters.js b/src/vue-poc/components/filters.js index f266b86..6352e2c 100644 --- a/src/vue-poc/components/filters.js +++ b/src/vue-poc/components/filters.js @@ -1,5 +1,9 @@ /** - * vue filters + * some vue filters, requires moment + * formatDate + * fromNow + * readablizeBytes + * round */ //Define the date time format filter diff --git a/src/vue-poc/core.js b/src/vue-poc/core.js index 4b5632a..f59cb86 100644 --- a/src/vue-poc/core.js +++ b/src/vue-poc/core.js @@ -101,14 +101,33 @@ localforage.config({ var settings = { debug: false, defaults:{ + "settings/ace": { - theme: "github", - keybinding: "ace", - fontsize: 16, - enableSnippets:true, - enableBasicAutocompletion:true, - enableLiveAutocompletion:true - }, + theme: "github", + keybinding: "ace", + fontsize: 16, + enableSnippets:true, + enableBasicAutocompletion:true, + enableLiveAutocompletion:true + }, + + "features/serviceworker": true, + "edit/items":[ + {name:"web.txt", id:"1", mode:"text", dirty: false, + text:`Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. +Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi +ut aliquip ex ea commodo consequat.`}, + + {name:"Shopping.xq", id:"2", mode: "xquery" ,dirty: false, + text:`let $a:=1 to 5 +return $a `}, + + {name:"videos.xml", id:"3", mode:"xml",dirty: false, location: "/aaa/bca/", + text:` + hello +`} + ] }, getItem (key) { if (this.debug) console.log('getItem',key); @@ -215,7 +234,9 @@ const Fullscreen={ }) } }; Vue.use(Fullscreen); -Vue.use(VueTreeselect); + +Vue.component('treeselect', VueTreeselect.Treeselect); + //Vue.use( VueFormJsonSchema); function install (Vue) { Vue.component('vue-form-json-schema', VueFormJsonSchema); diff --git a/src/vue-poc/data/vue-poc/history.xml b/src/vue-poc/data/vue-poc/history.xml index 867a27e..c22e142 100644 --- a/src/vue-poc/data/vue-poc/history.xml +++ b/src/vue-poc/data/vue-poc/history.xml @@ -1,6 +1,6 @@ - + diff --git a/src/vue-poc/expath-pkg.xml b/src/vue-poc/expath-pkg.xml index eb7cffd..0ea2b02 100644 --- a/src/vue-poc/expath-pkg.xml +++ b/src/vue-poc/expath-pkg.xml @@ -1,15 +1,16 @@ vue-poc test of vue.js. - + + - + - + diff --git a/src/vue-poc/features/collection/files.vue b/src/vue-poc/features/collection/files.vue index 7e3f08d..fab796e 100644 --- a/src/vue-poc/features/collection/files.vue +++ b/src/vue-poc/features/collection/files.vue @@ -12,7 +12,8 @@ - + + {{ item.name }} @@ -252,11 +253,11 @@ }, // array of {name:"that", path:"/this/that/"} for url crumbs(){ - var parts=this.url.split("/").filter((a)=>a.length>0) - var a=parts.map( - function(v,i,a){return {name:v, path:"/"+a.slice(0,i+1).join("/")+"/"}} - ) - return a + var url=this.url + return url.split("/").slice(0,-1).map( + function(v,i,a){return {name:v +"/", + path:a.slice(0,i+1).join("/")+"/"}} + ) }, selection(){ return this.items.filter(item=>{return item.selected} ) diff --git a/src/vue-poc/features/edit/tabs.vue b/src/vue-poc/features/edit/tabs.vue index 81004af..dada2a8 100644 --- a/src/vue-poc/features/edit/tabs.vue +++ b/src/vue-poc/features/edit/tabs.vue @@ -109,23 +109,7 @@ a1:"", currentItem: null, //href of current active: null, - items: [ - {name:"web.txt", id:"1", mode:"text", dirty: false, - text:`Lorem ipsum dolor sit amet, consectetur adipiscing elit, -sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. -Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi -ut aliquip ex ea commodo consequat.`}, - - {name:"Shopping.xq", id:"2", mode: "xquery" ,dirty: false, - text:`let $a:=1 to 5 -return $a `}, - - {name:"videos.xml", id:"3", mode:"xml",dirty: false, location: "/aaa/bca/", - text:` - hello -`}, - - ], + items: [], wrap: true, aceSettings: {}, mimeTypes:MimeTypes @@ -181,11 +165,13 @@ return $a `}, } }, }, + watch:{ currentItem: function (val) { this.active = this.items.find(e=> val=="T"+e.id) } }, + computed:{ sorted(){ return this.items.slice(0).sort((a,b) => a.name.localeCompare(b.name)) ; @@ -200,5 +186,18 @@ return $a `}, .then( v =>{ next(vm => {vm.aceSettings = v;}) }) - }, + settings.getItem('edit/items') + .then( v =>{ + next(vm => {vm.items = v;}) + }) + }, + + beforeRouteLeave (to, from, next) { + // called when the route that renders this component is about to + // be navigated away from. + // has access to `this` component instance. + settings.setItem('edit/items',this.items); + next(true); + } + } diff --git a/src/vue-poc/features/form/form-json-schema.vue b/src/vue-poc/features/form/form-json-schema.vue index 96abf48..cde913b 100644 --- a/src/vue-poc/features/form/form-json-schema.vue +++ b/src/vue-poc/features/form/form-json-schema.vue @@ -2,7 +2,7 @@