display expiration info
This commit is contained in:
parent
ce1b0c650e
commit
858a2a4e6c
|
@ -17,7 +17,9 @@
|
||||||
var ShareConfigModel = OC.Backbone.Model.extend({
|
var ShareConfigModel = OC.Backbone.Model.extend({
|
||||||
defaults: {
|
defaults: {
|
||||||
publicUploadEnabled: false,
|
publicUploadEnabled: false,
|
||||||
enforcePasswordForPublicLink: oc_appconfig.core.enforcePasswordForPublicLink
|
enforcePasswordForPublicLink: oc_appconfig.core.enforcePasswordForPublicLink,
|
||||||
|
isDefaultExpireDateEnforced: oc_appconfig.core.defaultExpireDateEnforced === true,
|
||||||
|
defaultExpireDate: oc_appconfig.core.defaultExpireDate,
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,13 +44,6 @@
|
||||||
return $('input:hidden[name=mailPublicNotificationEnabled]').val() === 'yes';
|
return $('input:hidden[name=mailPublicNotificationEnabled]').val() === 'yes';
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
isDefaultExpireDateEnforced: function() {
|
|
||||||
return oc_appconfig.core.defaultExpireDateEnforced === true;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
|
@ -75,13 +70,6 @@
|
||||||
*/
|
*/
|
||||||
getFederatedShareDocLink: function() {
|
getFederatedShareDocLink: function() {
|
||||||
return oc_appconfig.core.federatedCloudShareDoc;
|
return oc_appconfig.core.federatedCloudShareDoc;
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns {number}
|
|
||||||
*/
|
|
||||||
getDefaultExpireDate: function () {
|
|
||||||
return oc_appconfig.core.defaultExpireDate;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var TEMPLATE =
|
var TEMPLATE =
|
||||||
// well that could go to linkShareView…
|
// currently expiration is only effective for link share.
|
||||||
|
// this is about to change in future. Therefore this is not included
|
||||||
|
// in the LinkShareView to ease reusing it in future. Then,
|
||||||
|
// modifications (getting rid of IDs) are still necessary.
|
||||||
'{{#if isLinkShare}}' +
|
'{{#if isLinkShare}}' +
|
||||||
'<input type="checkbox" name="expirationCheckbox" id="expirationCheckbox" value="1" />' +
|
'<input type="checkbox" name="expirationCheckbox" id="expirationCheckbox" value="1" ' +
|
||||||
|
'{{#if isExpirationSet}}checked="checked"{{/if}} {{#if disableCheckbox}}disabled="disabled"{{/if}} />' +
|
||||||
'<label for="expirationCheckbox">{{setExpirationLabel}}</label>' +
|
'<label for="expirationCheckbox">{{setExpirationLabel}}</label>' +
|
||||||
'<label for="expirationDate" class="hidden-visually">{{expirationLabel}}</label>' +
|
' {{#if isExpirationSet}}' +
|
||||||
'<input id="expirationDate" type="text" placeholder="{{expirationDatePlaceholder}}" class="hidden" />' +
|
'<label for="expirationDate" class="hidden-visually" value="{{expirationDate}}">{{expirationLabel}}</label>' +
|
||||||
|
'<input id="expirationDate" class="datepicker" type="text" placeholder="{{expirationDatePlaceholder}}" />' +
|
||||||
|
' {{/if}}' +
|
||||||
|
' {{#if isExpirationEnforced}}' +
|
||||||
|
// originally the expire message was shown when a default date was set, however it never had text
|
||||||
'<em id="defaultExpireMessage">{{defaultExpireMessage}}</em>' +
|
'<em id="defaultExpireMessage">{{defaultExpireMessage}}</em>' +
|
||||||
|
' {{/if}}' +
|
||||||
'{{/if}}'
|
'{{/if}}'
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -59,24 +68,58 @@
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var defaultExpireMessage = '';
|
var defaultExpireMessage = '';
|
||||||
|
var defaultExpireDays = this.configModel.get('defaultExpireDate');
|
||||||
if( (this.model.isFolder() || this.model.isFile())
|
if( (this.model.isFolder() || this.model.isFile())
|
||||||
&& this.configModel.isDefaultExpireDateEnforced()) {
|
&& this.configModel.get('isDefaultExpireDateEnforced')) {
|
||||||
defaultExpireMessage = t(
|
defaultExpireMessage = t(
|
||||||
'core',
|
'core',
|
||||||
'The public link will expire no later than {days} days after it is created',
|
'The public link will expire no later than {days} days after it is created',
|
||||||
{'days': this.configModel.getDefaultExpireDate()}
|
{'days': defaultExpireDays }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isExpirationSet = !!this.model.get('linkShare').expiration;
|
||||||
|
var isExpirationEnforced = this.configModel.get('isDefaultExpireDateEnforced');
|
||||||
|
|
||||||
var expirationTemplate = this.template();
|
var expirationTemplate = this.template();
|
||||||
this.$el.html(expirationTemplate({
|
this.$el.html(expirationTemplate({
|
||||||
setExpirationLabel: t('core', 'Set expiration date'),
|
setExpirationLabel: t('core', 'Set expiration date'),
|
||||||
expirationLabel: t('core', 'Expiration'),
|
expirationLabel: t('core', 'Expiration'),
|
||||||
expirationDatePlaceholder: t('core', 'Expiration date'),
|
expirationDatePlaceholder: t('core', 'Expiration date'),
|
||||||
defaultExpireMessage: defaultExpireMessage,
|
defaultExpireMessage: defaultExpireMessage,
|
||||||
isLinkShare: this.model.get('linkShare').isLinkShare
|
isLinkShare: this.model.get('linkShare').isLinkShare,
|
||||||
|
isExpirationSet: isExpirationSet,
|
||||||
|
isExpirationEnforced: isExpirationEnforced,
|
||||||
|
disableCheckbox: isExpirationEnforced && isExpirationSet,
|
||||||
|
expirationValue: this.model.get('linkShare').expiration
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
if(isExpirationSet) {
|
||||||
|
// what if there is another date picker on that page?
|
||||||
|
var minDate = new Date();
|
||||||
|
// min date should always be the next day
|
||||||
|
minDate.setDate(minDate.getDate()+1);
|
||||||
|
|
||||||
|
var maxDate = null;
|
||||||
|
if(isExpirationEnforced) {
|
||||||
|
// TODO: hack: backend returns string instead of integer
|
||||||
|
var shareTime = this.model.get('linkShare').stime;
|
||||||
|
if (_.isNumber(shareTime)) {
|
||||||
|
shareTime = new Date(shareTime * 1000);
|
||||||
|
}
|
||||||
|
if (!shareTime) {
|
||||||
|
shareTime = new Date(); // now
|
||||||
|
}
|
||||||
|
shareTime = OC.Util.stripTime(shareTime).getTime();
|
||||||
|
maxDate = new Date(shareTime + defaultExpireDays * 24 * 3600 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.datepicker.setDefaults({
|
||||||
|
minDate: minDate,
|
||||||
|
maxDate: maxDate
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -134,6 +134,7 @@
|
||||||
$this.imageplaceholder($this.data('seed'));
|
$this.imageplaceholder($this.data('seed'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
this.$el.find('.datepicker').datepicker({dateFormat : 'dd-mm-yy'});
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
* @property {string} token
|
* @property {string} token
|
||||||
* @property {string|null} password
|
* @property {string|null} password
|
||||||
* @property {string} link
|
* @property {string} link
|
||||||
|
* @property {Date} expiration
|
||||||
|
* @property {number} stime share time
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -445,7 +447,10 @@
|
||||||
isLinkShare: true,
|
isLinkShare: true,
|
||||||
token: share.token,
|
token: share.token,
|
||||||
password: share.share_with,
|
password: share.share_with,
|
||||||
link: link
|
link: link,
|
||||||
|
// currently expiration is only effective for link shares.
|
||||||
|
expiration: share.expiration,
|
||||||
|
stime: share.stime
|
||||||
};
|
};
|
||||||
|
|
||||||
return share;
|
return share;
|
||||||
|
|
Loading…
Reference in New Issue