aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2017-03-29 16:50:23 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2017-04-03 10:29:32 +0200
commitb84fd7c3615c9d7b1830b6d51f6ad5b943d06b9f (patch)
tree2db691145f7ca15449a67d0b026a770f277561aa /core
parent3cc0d15f92175f01744cef0840e32d9b5657db3b (diff)
downloadnextcloud-server-b84fd7c3615c9d7b1830b6d51f6ad5b943d06b9f.tar.gz
nextcloud-server-b84fd7c3615c9d7b1830b6d51f6ad5b943d06b9f.zip
set expire date for all share types
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'core')
-rw-r--r--core/css/share.scss3
-rw-r--r--core/js/sharedialogshareelistview.js44
-rw-r--r--core/js/shareitemmodel.js14
3 files changed, 49 insertions, 12 deletions
diff --git a/core/css/share.scss b/core/css/share.scss
index 2c97af4aa0d..552e20c80cc 100644
--- a/core/css/share.scss
+++ b/core/css/share.scss
@@ -194,3 +194,6 @@ a {
width: inherit !important;
}
+.ui-datepicker {
+ z-index: 1111 !important;
+}
diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js
index 2f701ace759..b58c646be27 100644
--- a/core/js/sharedialogshareelistview.js
+++ b/core/js/sharedialogshareelistview.js
@@ -105,9 +105,9 @@
'<span class="shareOption menuitem">' +
'<input id="expireDate-{{cid}}-{{shareId}}" type="checkbox" name="expirationDate" class="expireDate checkbox" {{#if hasExpireDate}}checked="checked"{{/if}}" />' +
'<label for="expireDate-{{cid}}-{{shareId}}">{{expireDateLabel}}</label>' +
- '<div class="expirationDateContainer-{{cid}}-{{shareId}} {{#unless isExpirationSet}}hidden{{/unless}}">' +
+ '<div class="expirationDateContainer-{{cid}}-{{shareId}} {{#unless hasExpireDate}}hidden{{/unless}}">' +
' <label for="expirationDatePicker-{{cid}}-{{shareId}}" class="hidden-visually" value="{{expirationDate}}">{{expirationLabel}}</label>' +
- ' <input id="expirationDatePicker-{{cid}}-{{shareId}}" class="datepicker" type="text" placeholder="{{expirationDatePlaceholder}}" value="{{expirationValue}}" />' +
+ ' <input id="expirationDatePicker-{{cid}}-{{shareId}}" class="datepicker" type="text" placeholder="{{expirationDatePlaceholder}}" value="{{expireDate}}" />' +
'</div>' +
'</span>' +
'</li>' +
@@ -166,7 +166,9 @@
'click .password' : 'onMailSharePasswordProtectChange',
'click .secureDrop' : 'onSecureDropChange',
'keyup input.passwordField': 'onMailSharePasswordKeyUp',
- 'focusout input.passwordField': 'onMailSharePasswordEntered'
+ 'focusout input.passwordField': 'onMailSharePasswordEntered',
+ 'change .datepicker': 'onChangeExpirationDate',
+ 'click .datepicker' : 'showDatePicker'
},
initialize: function(options) {
@@ -237,6 +239,8 @@
isFileSharedByMail: shareType === OC.Share.SHARE_TYPE_EMAIL && !this.model.isFolder(),
isPasswordSet: hasPassword,
secureDropMode: !this.model.hasReadPermission(shareIndex),
+ hasExpireDate: this.model.getExpireDate(shareIndex) !== null,
+ expireDate: this.model.getExpireDate(shareIndex),
passwordPlaceholder: hasPassword ? PASSWORD_PLACEHOLDER : PASSWORD_PLACEHOLDER_MESSAGE,
});
},
@@ -464,19 +468,35 @@
var state = element.prop('checked');
datePicker.toggleClass('hidden', !state);
if (!state) {
- // discard expiration date
- this.model.get('linkShare').expiration = '';
- /*
- this.model.saveLinkShare({
- expireDate: ''
- });
- */
+ this.setExpirationDate(shareId, '');
} else {
- var expirationDatePicker = '#expirationDatePicker-' + this.cid + '-' + shareId;
- this.$(expirationDatePicker).focus();
+ this.showDatePicker(event);
+
}
},
+ showDatePicker: function(event) {
+ var element = $(event.target);
+ var li = element.closest('li[data-share-id]');
+ var shareId = li.data('share-id');
+ var expirationDatePicker = '#expirationDatePicker-' + this.cid + '-' + shareId;
+ $(expirationDatePicker).datepicker({dateFormat : 'dd-mm-yy'});
+ $(expirationDatePicker).focus();
+ },
+
+ onChangeExpirationDate: function(event) {
+ datePicker = $(event.target);
+ expireDate = datePicker.val();
+ var element = $(event.target);
+ var li = element.closest('li[data-share-id]');
+ var shareId = li.data('share-id');
+ this.setExpirationDate(shareId, expireDate);
+ },
+
+ setExpirationDate: function(shareId, expireDate) {
+ this.model.updateShare(shareId, {expireDate: expireDate}, {});
+ },
+
onMailSharePasswordProtectChange: function(event) {
var element = $(event.target);
var li = element.closest('li[data-share-id]');
diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js
index 8b0f71568c9..6bb8d75b91f 100644
--- a/core/js/shareitemmodel.js
+++ b/core/js/shareitemmodel.js
@@ -363,6 +363,10 @@
return this.get('reshare').share_type;
},
+ getExpireDate: function(shareIndex) {
+ return this._shareExpireDate(shareIndex);
+ },
+
/**
* Returns all share entries that only apply to the current item
* (file/folder)
@@ -449,6 +453,16 @@
return (share.permissions & permission) === permission;
},
+
+ _shareExpireDate: function(shareIndex) {
+ var share = this.get('shares')[shareIndex];
+ if(!_.isObject(share)) {
+ throw "Unknown Share";
+ }
+ var date2 = share.expiration;
+ return date2;
+ },
+
/**
* @returns {boolean}
*/