Commit 58a32dd5 authored by Anton Koch's avatar Anton Koch
Browse files

Merge branch '535-MoSys-Asset-Folder-Handling' into 'release_2_5'

Added tree structure to mosys asstes

See merge request !60
parents 8ce490b6 f9ed80c7
Pipeline #112342 passed with stage
in 10 seconds
......@@ -10,27 +10,14 @@
q-item.text-grey-8.text-italic.q-mt-sm(v-else) No Assets Found!
template(v-else)
template(v-if="userAssets.length" v-for="(asset, i) in userAssets")
// Single Assets
template(v-if="!asset.expandable")
q-item-separator.q-ma-none(v-if="i > 0", style="background-color: rgba(255,255,255,0.04);")
q-item.q-px-md.q-py-lg.media-item.custom-hover(@click.native="cacheNewCell(asset)")
q-item-main
q-item-tile.text-grey-3.q-mb-md {{ asset.title.length > 24 ? `${asset.title.slice(0, 24)}…` : asset.title }}
q-item-tile
img(:src="getAssetUrl(asset)" :alt="asset.title")
// Folder
template(v-else-if="asset.expandable && asset.childAssets.length")
q-item-separator.q-ma-none(v-if="i > 0", style="background-color: rgba(255,255,255,0.04);")
q-icon.q-px-md.q-py-lg(:name="asset.icon || 'folder'" size="24px" class="q-mr-sm")
span.q-pl-md {{ asset.label }}
template(v-for="(child, j) in asset.childAssets")
q-item.q-px-md.q-py-lg.q-pl-xl.media-item.custom-hover(@click.native="cacheNewCell(child)")
q-item-main
q-item-tile.text-grey-3.q-mb-md {{ child.title.length > 24 ? `${child.title.slice(0, 24)}…` : child.title }}
q-item-tile
img(:src="getAssetUrl(child)" :alt="child.title")
q-tree(v-if="userAssets.length" :nodes="userAssets" node-key="label" @lazy-load="onLazyLoad" default-expand-all dark)
q-item(slot="header-empty" slot-scope="prop")
span no asset
q-item(slot="default-header" slot-scope="prop")
.q-pa-sm
span.q-pr-md.q-pb-md {{ prop.node.label }}
q-item.media-item.custom-hover(v-if="prop.node.size" @click.native="cacheNewCell(prop.node)")
img.q-pa-md(:src="getAssetUrl(prop.node)" :alt="prop.node.title")
q-item.text-grey-8.text-italic.q-mt-sm(v-else) No Assets Found!
</template>
......@@ -120,17 +107,7 @@ export default {
else return 'folder'
},
async initUserAssets () {
this.userAssets = await this.listDir(this.bucket, true).then(result => {
const assets = []
// getting images in folder
result.forEach(async entry => {
if (!entry.size) {
entry.childAssets = await this.listDir(entry.fullpath)
}
assets.push(entry)
})
return assets
})
this.userAssets = await this.listDir(this.bucket, true)
},
transformEntries (entries) {
const children = [].concat(entries.filter(entry => !entry.size).map(node => ({
......@@ -156,6 +133,10 @@ export default {
}
return children
},
async onLazyLoad ({ node, done }) {
const entries = await this.listDir(node.fullpath)
done(entries)
},
async listDir (path, isRoot = false) {
this.$q.loading.show({ delay: 500 })
const entries = await this.$store.dispatch('assets/find', path)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment