mirror of
https://github.com/nextcloud/server.git
synced 2024-07-30 20:16:04 +02:00
split off expirationView
This commit is contained in:
parent
f9c232c4ce
commit
ffd4e0dc5a
93
core/js/sharedialogexpirationview.js
Normal file
93
core/js/sharedialogexpirationview.js
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015
|
||||||
|
*
|
||||||
|
* This file is licensed under the Affero General Public License version 3
|
||||||
|
* or later.
|
||||||
|
*
|
||||||
|
* See the COPYING-README file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
if (!OC.Share) {
|
||||||
|
OC.Share = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
var TEMPLATE =
|
||||||
|
'<input type="checkbox" name="expirationCheckbox" id="expirationCheckbox" value="1" />' +
|
||||||
|
'<label for="expirationCheckbox">{{setExpirationLabel}}</label>' +
|
||||||
|
'<label for="expirationDate" class="hidden-visually">{{expirationLabel}}</label>' +
|
||||||
|
'<input id="expirationDate" type="text" placeholder="{{expirationDatePlaceholder}}" class="hidden" />' +
|
||||||
|
'<em id="defaultExpireMessage">{{defaultExpireMessage}}</em>'
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class OCA.Share.ShareDialogExpirationView
|
||||||
|
* @member {OC.Share.ShareItemModel} model
|
||||||
|
* @member {jQuery} $el
|
||||||
|
* @memberof OCA.Sharing
|
||||||
|
* @classdesc
|
||||||
|
*
|
||||||
|
* Represents the expiration part in the GUI of the share dialogue
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
var ShareDialogExpirationView = OC.Backbone.View.extend({
|
||||||
|
/** @type {string} **/
|
||||||
|
id: 'shareDialogLinkShare',
|
||||||
|
|
||||||
|
/** @type {OC.Share.ShareConfigModel} **/
|
||||||
|
configModel: undefined,
|
||||||
|
|
||||||
|
/** @type {Function} **/
|
||||||
|
_template: undefined,
|
||||||
|
|
||||||
|
/** @type {boolean} **/
|
||||||
|
showLink: true,
|
||||||
|
|
||||||
|
initialize: function(options) {
|
||||||
|
if(!_.isUndefined(options.configModel)) {
|
||||||
|
this.configModel = options.configModel;
|
||||||
|
} else {
|
||||||
|
console.warn('missing OC.Share.ShareConfigModel');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
var defaultExpireMessage = '';
|
||||||
|
if( (this.model.isFolder() || this.model.isFile())
|
||||||
|
&& this.configModel.isDefaultExpireDateEnforced()) {
|
||||||
|
defaultExpireMessage = t(
|
||||||
|
'core',
|
||||||
|
'The public link will expire no later than {days} days after it is created',
|
||||||
|
{'days': this.configModel.getDefaultExpireDate()}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
var expirationTemplate = this.template();
|
||||||
|
this.$el.empty();
|
||||||
|
this.$el.append(expirationTemplate({
|
||||||
|
setExpirationLabel: t('core', 'Set expiration date'),
|
||||||
|
expirationLabel: t('core', 'Expiration'),
|
||||||
|
expirationDatePlaceholder: t('core', 'Expiration date'),
|
||||||
|
defaultExpireMessage: defaultExpireMessage
|
||||||
|
}));
|
||||||
|
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {Function} from Handlebars
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
template: function () {
|
||||||
|
if (!this._template) {
|
||||||
|
this._template = Handlebars.compile(TEMPLATE);
|
||||||
|
}
|
||||||
|
return this._template;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
OC.Share.ShareDialogExpirationView = ShareDialogExpirationView;
|
||||||
|
|
||||||
|
})();
|
@ -14,7 +14,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var TEMPLATE_BASE =
|
var TEMPLATE_BASE =
|
||||||
'<div class="resharerInfo"></div>' +
|
'<div class="resharerInfoView"></div>' +
|
||||||
'<label for="shareWith" class="hidden-visually">{{shareLabel}}</label>' +
|
'<label for="shareWith" class="hidden-visually">{{shareLabel}}</label>' +
|
||||||
'<div class="oneline">' +
|
'<div class="oneline">' +
|
||||||
' <input id="shareWith" type="text" placeholder="{{sharePlaceholder}}" />' +
|
' <input id="shareWith" type="text" placeholder="{{sharePlaceholder}}" />' +
|
||||||
@ -25,11 +25,11 @@
|
|||||||
'<ul id="shareWithList">' +
|
'<ul id="shareWithList">' +
|
||||||
'</ul>' +
|
'</ul>' +
|
||||||
'{{#if shareAllowed}}' +
|
'{{#if shareAllowed}}' +
|
||||||
'<div class="linkShare"></div>' +
|
'<div class="linkShareView"></div>' +
|
||||||
'{{else}}' +
|
'{{else}}' +
|
||||||
'{{{noSharing}}}' +
|
'{{{noSharing}}}' +
|
||||||
'{{/if}}' +
|
'{{/if}}' +
|
||||||
'{{{expiration}}}'
|
'<div class="expirationView"></div>'
|
||||||
;
|
;
|
||||||
|
|
||||||
var TEMPLATE_REMOTE_SHARE_INFO =
|
var TEMPLATE_REMOTE_SHARE_INFO =
|
||||||
@ -40,16 +40,6 @@
|
|||||||
'<input id="shareWith" type="text" placeholder="{{placeholder}}" disabled="disabled"/>'
|
'<input id="shareWith" type="text" placeholder="{{placeholder}}" disabled="disabled"/>'
|
||||||
;
|
;
|
||||||
|
|
||||||
var TEMPLATE_EXPIRATION =
|
|
||||||
'<div id="expiration">' +
|
|
||||||
' <input type="checkbox" name="expirationCheckbox" id="expirationCheckbox" value="1" />' +
|
|
||||||
' <label for="expirationCheckbox">{{setExpirationLabel}}</label>' +
|
|
||||||
' <label for="expirationDate" class="hidden-visually">{{expirationLabel}}</label>' +
|
|
||||||
' <input id="expirationDate" type="text" placeholder="{{expirationDatePlaceholder}}" class="hidden" />' +
|
|
||||||
' <em id="defaultExpireMessage">{{defaultExpireMessage}}</em>' +
|
|
||||||
'</div>'
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class OCA.Share.ShareDialogView
|
* @class OCA.Share.ShareDialogView
|
||||||
* @member {OC.Share.ShareItemModel} model
|
* @member {OC.Share.ShareItemModel} model
|
||||||
@ -79,6 +69,9 @@
|
|||||||
/** @type {object} **/
|
/** @type {object} **/
|
||||||
linkShareView: undefined,
|
linkShareView: undefined,
|
||||||
|
|
||||||
|
/** @type {object} **/
|
||||||
|
expirationView: undefined,
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
var view = this;
|
var view = this;
|
||||||
this.model.on('change', function() {
|
this.model.on('change', function() {
|
||||||
@ -108,6 +101,10 @@
|
|||||||
? new OC.Share.ShareDialogLinkShareView(subViewOptions)
|
? new OC.Share.ShareDialogLinkShareView(subViewOptions)
|
||||||
: options.linkShareView;
|
: options.linkShareView;
|
||||||
|
|
||||||
|
this.expirationView = _.isUndefined(options.expirationView)
|
||||||
|
? new OC.Share.ShareDialogExpirationView(subViewOptions)
|
||||||
|
: options.expirationView;
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
@ -119,14 +116,16 @@
|
|||||||
remoteShareInfo: this._renderRemoteShareInfoPart(),
|
remoteShareInfo: this._renderRemoteShareInfoPart(),
|
||||||
shareAllowed: this.model.hasSharePermission(),
|
shareAllowed: this.model.hasSharePermission(),
|
||||||
noSharing: this._renderNoSharing(),
|
noSharing: this._renderNoSharing(),
|
||||||
expiration: this._renderExpirationPart()
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.resharerInfoView.$el = this.$el.find('.resharerInfo');
|
this.resharerInfoView.$el = this.$el.find('.resharerInfoView');
|
||||||
this.resharerInfoView.render();
|
this.resharerInfoView.render();
|
||||||
|
|
||||||
|
this.expirationView.$el = this.$el.find('.expirationView');
|
||||||
|
this.expirationView.render();
|
||||||
|
|
||||||
if(this.model.hasSharePermission()) {
|
if(this.model.hasSharePermission()) {
|
||||||
this.linkShareView.$el = this.$el.find('.linkShare');
|
this.linkShareView.$el = this.$el.find('.linkShareView');
|
||||||
this.linkShareView.render();
|
this.linkShareView.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,29 +180,6 @@
|
|||||||
return noSharing;
|
return noSharing;
|
||||||
},
|
},
|
||||||
|
|
||||||
_renderExpirationPart: function() {
|
|
||||||
var expirationTemplate = this._getTemplate('expiration', TEMPLATE_EXPIRATION);
|
|
||||||
|
|
||||||
var defaultExpireMessage = '';
|
|
||||||
if(( this.model.isFolder() || this.model.isFile())
|
|
||||||
&& this.configModel.isDefaultExpireDateEnforced()) {
|
|
||||||
defaultExpireMessage = t(
|
|
||||||
'core',
|
|
||||||
'The public link will expire no later than {days} days after it is created',
|
|
||||||
{'days': this.configModel.getDefaultExpireDate()}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
var expiration = expirationTemplate({
|
|
||||||
setExpirationLabel: t('core', 'Set expiration date'),
|
|
||||||
expirationLabel: t('core', 'Expiration'),
|
|
||||||
expirationDatePlaceholder: t('core', 'Expiration date'),
|
|
||||||
defaultExpireMessage: defaultExpireMessage
|
|
||||||
});
|
|
||||||
|
|
||||||
return expiration;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {string} key - an identifier for the template
|
* @param {string} key - an identifier for the template
|
||||||
|
@ -87,6 +87,7 @@ class Share extends Constants {
|
|||||||
\OC_Util::addScript('core', 'shareitemmodel');
|
\OC_Util::addScript('core', 'shareitemmodel');
|
||||||
\OC_Util::addScript('core', 'sharedialogresharerinfoview');
|
\OC_Util::addScript('core', 'sharedialogresharerinfoview');
|
||||||
\OC_Util::addScript('core', 'sharedialoglinkshareview');
|
\OC_Util::addScript('core', 'sharedialoglinkshareview');
|
||||||
|
\OC_Util::addScript('core', 'sharedialogexpirationview');
|
||||||
\OC_Util::addScript('core', 'sharedialogview');
|
\OC_Util::addScript('core', 'sharedialogview');
|
||||||
\OC_Util::addScript('core', 'share');
|
\OC_Util::addScript('core', 'share');
|
||||||
\OC_Util::addStyle('core', 'share');
|
\OC_Util::addStyle('core', 'share');
|
||||||
|
Loading…
Reference in New Issue
Block a user