Skip to content

Commit

Permalink
feat: filetype filter in Media list
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed Sep 6, 2021
1 parent 8da2985 commit c11d19a
Show file tree
Hide file tree
Showing 14 changed files with 161 additions and 42 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

setup(
name='unicms-editorial-board',
version='0.21.1',
version='0.22.0',

packages=[PKG_NAME],
package_dir={PKG_NAME: f"{SRC_FOLDER}/{PKG_NAME}"},
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
self.__precacheManifest = [
{
"revision": "612a99c10e9fdfb628e6",
"revision": "38c3e335d2ecdfe70f90",
"url": "/static/unicms_editorial_board_vue/css/app.bca404fa.css"
},
{
"revision": "612a99c10e9fdfb628e6",
"url": "/static/unicms_editorial_board_vue/js/app.fe682ef6.js"
"revision": "38c3e335d2ecdfe70f90",
"url": "/static/unicms_editorial_board_vue/js/app.ba40fcf9.js"
},
{
"revision": "9c41a8a956028c357565",
"revision": "43fc4a4cc52bf4236d47",
"url": "/static/unicms_editorial_board_vue/css/chunk-vendors.25bdde32.css"
},
{
"revision": "9c41a8a956028c357565",
"url": "/static/unicms_editorial_board_vue/js/chunk-vendors.b3ebd97f.js"
"revision": "43fc4a4cc52bf4236d47",
"url": "/static/unicms_editorial_board_vue/js/chunk-vendors.af3c99db.js"
},
{
"revision": "bf27c386d768278a2e32eb16873f824d",
"revision": "3938067b3610e41b697948226c7fbee5",
"url": "/static/unicms_editorial_board_vue/index.html"
},
{
Expand Down Expand Up @@ -87,14 +87,14 @@ self.__precacheManifest = [
"revision": "f575a04ebbb31b5798a4c54783e745a2",
"url": "/static/unicms_editorial_board_vue/img/new_logo.png"
},
{
"revision": "6be21e8a1b7d63048728851c6003e189",
"url": "/static/unicms_editorial_board_vue/img/sidebar-1.jpg"
},
{
"revision": "7a4ce7cc040fc1cb8176cde106e9232f",
"url": "/static/unicms_editorial_board_vue/img/sidebar-2.jpg"
},
{
"revision": "6be21e8a1b7d63048728851c6003e189",
"url": "/static/unicms_editorial_board_vue/img/sidebar-1.jpg"
},
{
"revision": "cd253e23ed052deeb80b42d2ed772183",
"url": "/static/unicms_editorial_board_vue/img/sidebar-3.jpg"
Expand All @@ -103,10 +103,6 @@ self.__precacheManifest = [
"revision": "897b4cf909210560a84398d36da51983",
"url": "/static/unicms_editorial_board_vue/img/sidebar-4.jpg"
},
{
"revision": "9ebea76ee1225f00d882b21547a7b49f",
"url": "/static/unicms_editorial_board_vue/img/sidebar-5.jpg"
},
{
"revision": "44bf13a71a4db6e15913fe8af9296711",
"url": "/static/unicms_editorial_board_vue/img/tim_80x80.png"
Expand All @@ -115,6 +111,10 @@ self.__precacheManifest = [
"revision": "c2a605fbc0e687b2e1b4b90a7c445cdd",
"url": "/static/unicms_editorial_board_vue/img/vue-logo.png"
},
{
"revision": "9ebea76ee1225f00d882b21547a7b49f",
"url": "/static/unicms_editorial_board_vue/img/sidebar-5.jpg"
},
{
"revision": "b6216d61c03e6ce0c9aea6ca7808f7ca",
"url": "/static/unicms_editorial_board_vue/robots.txt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js");

importScripts(
"/static/unicms_editorial_board_vue/precache-manifest.43863ba9f72a86d62cfe4fd2b511f0ad.js"
"/static/unicms_editorial_board_vue/precache-manifest.72a56627d336db5d41356398a58ee74c.js"
);

workbox.core.setCacheNameDetails({prefix: "vue-light-bootstrap-dashboard"});
Expand Down
2 changes: 1 addition & 1 deletion src/unicms_editorial_board/templates/board.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset="utf-8"><link rel="apple-touch-icon" sizes="76x76" href="/static/unicms_editorial_board_vue/apple-icon.png"><!--[if IE]><link rel="icon" type="image/png" sizes="96x96" href="/static/unicms_editorial_board_vue/favicon.png"><![endif]--><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title>uniCMS - Editorial Board</title><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"><link href="https://fonts.googleapis.com/css?family=Montserrat:400,700,200" rel="stylesheet"><link href="/static/unicms_editorial_board_vue/css/app.bca404fa.css" rel="preload" as="style"><link href="/static/unicms_editorial_board_vue/css/chunk-vendors.25bdde32.css" rel="preload" as="style"><link href="/static/unicms_editorial_board_vue/js/app.fe682ef6.js" rel="preload" as="script"><link href="/static/unicms_editorial_board_vue/js/chunk-vendors.b3ebd97f.js" rel="preload" as="script"><link href="/static/unicms_editorial_board_vue/css/chunk-vendors.25bdde32.css" rel="stylesheet"><link href="/static/unicms_editorial_board_vue/css/app.bca404fa.css" rel="stylesheet"><link rel="icon" type="image/png" sizes="32x32" href="/static/unicms_editorial_board_vue/img/icons/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/static/unicms_editorial_board_vue/img/icons/favicon-16x16.png"><link rel="manifest" href="/static/unicms_editorial_board_vue/manifest.json"><meta name="theme-color" content="#344675"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="#344675"><meta name="apple-mobile-web-app-title" content="uniCMS - Unical Editorial Board"><link rel="apple-touch-icon" href="/static/unicms_editorial_board_vue/img/icons/apple-touch-icon-152x152.png"><link rel="mask-icon" href="/static/unicms_editorial_board_vue/img/icons/safari-pinned-tab.svg" color="#344675"><meta name="msapplication-TileImage" content="/static/unicms_editorial_board_vue/img/icons/msapplication-icon-144x144.png"><meta name="msapplication-TileColor" content="#344675"></head><body><div id="app"></div><script src="/static/unicms_editorial_board_vue/js/chunk-vendors.b3ebd97f.js"></script><script src="/static/unicms_editorial_board_vue/js/app.fe682ef6.js"></script></body></html>
<!DOCTYPE html><html><head><meta charset="utf-8"><link rel="apple-touch-icon" sizes="76x76" href="/static/unicms_editorial_board_vue/apple-icon.png"><!--[if IE]><link rel="icon" type="image/png" sizes="96x96" href="/static/unicms_editorial_board_vue/favicon.png"><![endif]--><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title>uniCMS - Editorial Board</title><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"><link href="https://fonts.googleapis.com/css?family=Montserrat:400,700,200" rel="stylesheet"><link href="/static/unicms_editorial_board_vue/css/app.bca404fa.css" rel="preload" as="style"><link href="/static/unicms_editorial_board_vue/css/chunk-vendors.25bdde32.css" rel="preload" as="style"><link href="/static/unicms_editorial_board_vue/js/app.ba40fcf9.js" rel="preload" as="script"><link href="/static/unicms_editorial_board_vue/js/chunk-vendors.af3c99db.js" rel="preload" as="script"><link href="/static/unicms_editorial_board_vue/css/chunk-vendors.25bdde32.css" rel="stylesheet"><link href="/static/unicms_editorial_board_vue/css/app.bca404fa.css" rel="stylesheet"><link rel="icon" type="image/png" sizes="32x32" href="/static/unicms_editorial_board_vue/img/icons/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/static/unicms_editorial_board_vue/img/icons/favicon-16x16.png"><link rel="manifest" href="/static/unicms_editorial_board_vue/manifest.json"><meta name="theme-color" content="#344675"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="#344675"><meta name="apple-mobile-web-app-title" content="uniCMS - Unical Editorial Board"><link rel="apple-touch-icon" href="/static/unicms_editorial_board_vue/img/icons/apple-touch-icon-152x152.png"><link rel="mask-icon" href="/static/unicms_editorial_board_vue/img/icons/safari-pinned-tab.svg" color="#344675"><meta name="msapplication-TileImage" content="/static/unicms_editorial_board_vue/img/icons/msapplication-icon-144x144.png"><meta name="msapplication-TileColor" content="#344675"></head><body><div id="app"></div><script src="/static/unicms_editorial_board_vue/js/chunk-vendors.af3c99db.js"></script><script src="/static/unicms_editorial_board_vue/js/app.ba40fcf9.js"></script></body></html>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"axios": "^0.21.1",
"bootstrap-vue": "^2.21.2",
"chartist": "^0.11.0",
"chokidar": "^3.5.2",
"node-sass": "^4.14.1",
"register-service-worker": "^1.5.2",
"vue": "^2.6.12",
"vue-2-breadcrumbs": "^0.7.12",
Expand All @@ -29,10 +31,9 @@
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.4.0",
"@vue/cli-plugin-eslint": "^3.4.0",
"@vue/cli-plugin-eslint": "^3.1.1",
"@vue/cli-plugin-pwa": "^3.4.0",
"@vue/cli-service": "^4.5.11",
"node-sass": "^4.11.0",
"@vue/cli-service": "^4.5.13",
"sass-loader": "^7.1.0",
"vue-template-compiler": "^2.6.6"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<template>
<b-input-group>
<b-form-select
class="mb-3"
id="media-filetype-select"
v-model="media_type"
v-on:change="updateMediaType()"
:options="type_list"
:aria-describedby="ariaDescribedby">
</b-form-select>
</b-input-group>
</template>
<script>
export default {
name: 'MediaTypeFilter',
props: {
media_type: { type: String },
},
data () {
return {
types_list: []
}
},
methods: {
callMediaFiltersApi() {
let source = '/api/editorial-board/medias/allowed-filetypes/';
this.axios
.get(source)
.then(response => {
this.types_list = response
console.log(this.types_list)
})
},
updateMediaTypeFilter() {
this.$emit('updateMediaTypeFilter', this.media_type);
this.$emit('callApi');
}
},
mounted() {
this.callMediaFiltersApi()
}
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
@callApi="callApi(null, 1)"
/>
</div>

<slot name="custom_filter"></slot>

<div class="col col-12 col-md-4">
<OrderingFilter
:ordering="ordering"
Expand Down Expand Up @@ -231,6 +234,7 @@ export default {
{ text: 'Only items created by me', value: ''},
{ text: 'Show all items', value: ''},
],
custom_filters: {}
}
},
methods: {
Expand Down Expand Up @@ -258,6 +262,7 @@ export default {
})
},
callApi(url=null, page=null) {
if (this.mainMethod) {
this.mainMethod(url, page);
}
Expand All @@ -269,6 +274,12 @@ export default {
'&ordering=' + this.sortDesc + this.ordering +
'&created_by=' + this.created_by +
'&is_active=' + this.is_active;
for (let [key, value] of Object.entries(this.custom_filters)) {
let filter = '&' + key + '=' + value
source = source.concat(filter);
}
if (url) source = url;
this.axios
.get(source)
Expand All @@ -289,6 +300,11 @@ export default {
'sortDesc': this.sortDesc,
'created_by': this.created_by,
}
for (let [key, value] of Object.entries(this.custom_filters)) {
params[key] = value
}
sessionStorage.setItem(this.parent_name, JSON.stringify(params))
})
}
Expand Down Expand Up @@ -362,11 +378,26 @@ export default {
if(sessionStorage.getItem(this.parent_name)){
let init = JSON.parse(sessionStorage.getItem(this.parent_name))
this.is_active = init['is_active']
delete init['is_active']
this.page = init['page']
delete init['page']
this.search = init['search']
delete init['search']
this.ordering = init['ordering']
delete init['ordering']
this.created_by = init['created_by']
delete init['created_by']
this.sortDesc = init['sortDesc']
delete init['sortDesc']
for (let [key, value] of Object.entries(init)) {
this.custom_filters[key] = value
}
}
if (this.showCreatedBy) this.getCurrentUserID();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
:ordering="ordering"
:ordering_list="ordering_list"
:page_title="page_title"
:showIsActive="false" >
:showIsActive="false"
ref="completeTable">

<template #add_new>
<router-link :to="{ name: 'MediaNew'}"
Expand All @@ -17,6 +18,28 @@
</router-link>
</template>

<template #custom_filter>
<div class="col col-12 col-sm">
<b-input-group>
<b-form-select
class="mb-3"
id="media-filetype-select"
v-on:change="updateMediaType($event)"
v-model="file_type"
:aria-describedby="ariaDescribedby">
<b-form-select-option value="">
- All file types -
</b-form-select-option>
<b-form-select-option
v-for="filetype in types_list"
:value="filetype">
{{ filetype }}
</b-form-select-option>
</b-form-select>
</b-input-group>
</div>
</template>

<template #actions="item">
<router-link :to="{ name: 'MediaEdit',
params: { media_id: item.item.id }}"
Expand All @@ -38,6 +61,7 @@
</template>
<script>
import CompleteTable from '../layout/CompleteTable.vue'
import MediaTypeFilter from '../components/Tables/MediaTypeFilter.vue'
export default {
components: {
Expand Down Expand Up @@ -65,8 +89,28 @@ export default {
{ text: 'Description', value: 'description' },
{ text: 'File type', value: 'file_type' },
],
file_type: '',
types_list: [],
page_title: 'Media'
}
},
methods: {
callMediaFiltersApi() {
let source = '/api/editorial-board/medias/allowed-filetypes/';
this.axios
.get(source)
.then(response => {
this.types_list = response.data
})
},
updateMediaType(value) {
this.$refs.completeTable.custom_filters.file_type = value
this.$refs.completeTable.callApi(null, 1)
}
},
mounted() {
this.file_type = this.$refs.completeTable.custom_filters.file_type
this.callMediaFiltersApi()
}
}
</script>

0 comments on commit c11d19a

Please sign in to comment.