Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/Cockpit/assets/cockpit.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,14 @@
select: function(callback, options){

options = App.$.extend({
pattern: "*.*",
selected : []
}, options);

var selected = [], dialog = UIkit.modal.dialog([
'<div>',
'<div class="uk-modal-header uk-text-large">'+App.i18n.get('Select asset')+'</div>',
'<cp-assets path="'+(options.path || '')+'" typefilter="'+(options.typefilter || '')+'" modal="true"></cp-assets>',
'<cp-assets pattern="' + (options.pattern || '*.*') + '" path="'+(options.path || '')+'" typefilter="'+(options.typefilter || '')+'" modal="true"></cp-assets>',
'<div class="uk-modal-footer uk-text-right">',
'<button class="uk-button uk-button-primary uk-margin-right uk-button-large uk-hidden js-select-button">'+App.i18n.get('Select')+': <span></span> item(s)</button>',
'<a class="uk-button uk-button-large uk-button-link uk-modal-close">'+App.i18n.get('Close')+'</a>',
Expand Down
16 changes: 12 additions & 4 deletions modules/Cockpit/assets/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,19 @@ riot.tag2('cp-assets', '<div ref="list" show="{mode==\'list\'}"> <div ref="uploa
this.page = 1;
this.pages = 1;
this.limit = opts.limit || 15;
this.pattern = opts.pattern || '*.*'

this.on('mount', function() {

this.listAssets(1);
this.updateFilter();

App.assets.require(['/assets/lib/uikit/js/components/upload.js'], function() {

var uploadSettings = {

action: App.route('/assetsmanager/upload'),
type: 'json',
allow: $this.pattern,
before: function(options) {
options.params.folder = $this.folder
},
Expand Down Expand Up @@ -176,7 +178,8 @@ riot.tag2('cp-assets', '<div ref="list" show="{mode==\'list\'}"> <div ref="uploa
App.ui.notify("Something went wrong.", "danger");
}

}
},

},

uploadselect = UIkit.uploadSelect(App.$('.js-upload-select', $this.root)[0], uploadSettings),
Expand Down Expand Up @@ -232,10 +235,14 @@ riot.tag2('cp-assets', '<div ref="list" show="{mode==\'list\'}"> <div ref="uploa

this.filter = null;

if (this.refs.filtertitle.value || this.refs.filtertype.value) {
if (this.refs.filtertitle.value || this.refs.filtertype.value || this.pattern !== '*.*') {
this.filter = {};
}

if (this.pattern !== '*.*') {
this.filter.path = {'$regex': '^.*\.(' + this.pattern.replace(/\*./g, '') + ')$', '$options': 'i'};
}

if (this.refs.filtertitle.value) {

this.filter.$or = [];
Expand Down Expand Up @@ -1856,6 +1863,7 @@ riot.tag2('field-asset', '<div ref="uploadprogress" class="uk-margin uk-hidden">
}.bind(this);

this.on('mount', function() {
$this.pattern = opts.pattern || '*.*';

App.assets.require(['/assets/lib/uikit/js/components/upload.js'], function() {

Expand Down Expand Up @@ -1904,7 +1912,7 @@ riot.tag2('field-asset', '<div ref="uploadprogress" class="uk-margin uk-hidden">
if (Array.isArray(assets)) {
$this.$setValue(assets[0]);
}
});
}, { pattern: $this.pattern });
}.bind(this)

this.reset = function() {
Expand Down
13 changes: 10 additions & 3 deletions modules/Cockpit/assets/components/cp-assets.tag
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,11 @@
this.page = 1;
this.pages = 1;
this.limit = opts.limit || 15;
this.pattern = opts.pattern || '*.*'

this.on('mount', function() {

this.listAssets(1);
this.updateFilter();

// handle uploads
App.assets.require(['/assets/lib/uikit/js/components/upload.js'], function() {
Expand All @@ -284,6 +285,7 @@

action: App.route('/assetsmanager/upload'),
type: 'json',
allow: $this.pattern,
before: function(options) {
options.params.folder = $this.folder
},
Expand Down Expand Up @@ -324,7 +326,8 @@
App.ui.notify("Something went wrong.", "danger");
}

}
},

},

uploadselect = UIkit.uploadSelect(App.$('.js-upload-select', $this.root)[0], uploadSettings),
Expand Down Expand Up @@ -380,10 +383,14 @@

this.filter = null;

if (this.refs.filtertitle.value || this.refs.filtertype.value) {
if (this.refs.filtertitle.value || this.refs.filtertype.value || this.pattern !== '*.*') {
this.filter = {};
}

if (this.pattern !== '*.*') {
this.filter.path = {'$regex': '^.*\.(' + this.pattern.replace(/\*./g, '') + ')$', '$options': 'i'};
}

if (this.refs.filtertitle.value) {

this.filter.$or = [];
Expand Down
3 changes: 2 additions & 1 deletion modules/Cockpit/assets/components/field-asset.tag
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
}.bind(this);

this.on('mount', function() {
$this.pattern = opts.pattern || '*.*';

// handle uploads
App.assets.require(['/assets/lib/uikit/js/components/upload.js'], function() {
Expand Down Expand Up @@ -128,7 +129,7 @@
if (Array.isArray(assets)) {
$this.$setValue(assets[0]);
}
});
}, { pattern: $this.pattern });
}

reset() {
Expand Down