Skip to content

Commit

Permalink
Make link, group and user expiration texts the same. Some minor adjus…
Browse files Browse the repository at this point in the history
…tments to share expiration js code
  • Loading branch information
phil-davis authored and mrow4a committed Jan 23, 2020
1 parent e079491 commit 0e4ba37
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 29 deletions.
2 changes: 1 addition & 1 deletion apps/files_sharing/css/sharetabview.css
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
font-size: 1px;
}

.shareDialogExpirationView .error-message,
.shareDialogLinkExpirationView .error-message,
.linkPass .error-message {
color: red;
padding: 4px;
Expand Down
1 change: 1 addition & 0 deletions changelog/unreleased/36573
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ be enabled on the admin sharing settings page. They can be set independently for
user and group shares.

https://github.com/owncloud/core/pull/36573
https://github.com/owncloud/core/pull/36766
2 changes: 1 addition & 1 deletion core/js/core.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"sharescollection.js",
"shareitemmodel.js",
"sharedialogview.js",
"sharedialogexpirationview.js",
"sharedialoglinkexpirationview.js",
"sharedialoglinkshareview.js",
"sharedialoglinklistview.js",
"sharedialogmailview.js",
Expand Down
10 changes: 5 additions & 5 deletions core/js/shareconfigmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,28 +104,28 @@
* @returns {boolean}
*/
isDefaultExpireDateUserEnabled: function() {
return this.get('isDefaultExpireDateUserEnabled')
return this.get('isDefaultExpireDateUserEnabled');
},

/**
* @returns {boolean}
*/
isDefaultExpireDateUserEnforced: function() {
return this.get('isDefaultExpireDateUserEnforced')
return this.get('isDefaultExpireDateUserEnforced');
},

/**
* @returns {number/string}
*/
getDefaultExpireDateUser: function(format) {
format = format || false;
defaultExpireDateUser = parseInt(this.get('defaultExpireDateUser'), 10)
var defaultExpireDateUser = parseInt(this.get('defaultExpireDateUser'), 10);

if (format) {
return moment().add(defaultExpireDateUser, 'days').format(format)
return moment().add(defaultExpireDateUser, 'days').format(format);
}

return defaultExpireDateUser
return defaultExpireDateUser;
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
;

/**
* @class OCA.Share.ShareDialogExpirationView
* @class OCA.Share.ShareDialogLinkExpirationView
* @member {OC.Share.ShareItemModel} model
* @member {jQuery} $el
* @memberof OCA.Sharing
Expand All @@ -37,17 +37,17 @@
* Represents the expiration part in the GUI of the share dialogue
*
*/
var ShareDialogExpirationView = OC.Backbone.View.extend({
var ShareDialogLinkExpirationView = OC.Backbone.View.extend({
/** @type {string} **/
id: 'shareDialogExpirationView',
id: 'shareDialogLinkExpirationView',

/** @type {OC.Share.ShareConfigModel} **/
configModel: undefined,

/** @type {Function} **/
_template: undefined,

className: 'shareDialogExpirationView',
className: 'shareDialogLinkExpirationView',

events: {
'change .expirationCheckbox': '_onToggleExpiration',
Expand Down Expand Up @@ -104,13 +104,11 @@

this.$el.html(this.template({
cid: this.cid,
setExpirationLabel: t('core', 'Set expiration date'),
expirationLabel: t('core', 'Expiration'),
expirationDatePlaceholder: t('core', 'Choose an expiration date'),
defaultExpireMessage: defaultExpireMessage,
isExpirationSet: isExpirationSet,
isExpirationEnforced: isExpirationEnforced,
disableCheckbox: isExpirationEnforced && isExpirationSet,
expirationValue: expiration
}));

Expand Down Expand Up @@ -176,6 +174,6 @@

});

OC.Share.ShareDialogExpirationView = ShareDialogExpirationView;
OC.Share.ShareDialogLinkExpirationView = ShareDialogLinkExpirationView;

})();
2 changes: 1 addition & 1 deletion core/js/sharedialoglinkshareview.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
throw 'missing OC.Share.ShareItemModel';
}

this.expirationView = new OC.Share.ShareDialogExpirationView({
this.expirationView = new OC.Share.ShareDialogLinkExpirationView({
model: this.model,
itemModel: this.itemModel
});
Expand Down
27 changes: 17 additions & 10 deletions core/js/sharedialogshareelistview.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,19 @@
' {{/unless}} {{/if}}' +
' <div class="expirationOption">' +
' {{#if isUserShare}}' +
' <label for="expiration-{{name}}-{{cid}}-{{shareWith}}">Expiration: ' +
' <input type="text" id="expiration-{{name}}-{{cid}}-{{shareWith}}" value="{{expirationDate}}" class="expiration expiration-user" placeholder="Choose an expiration date" />' +
' <label for="expiration-{{name}}-{{cid}}-{{shareWith}}">{{expirationLabel}}: ' +
' <input type="text" id="expiration-{{name}}-{{cid}}-{{shareWith}}" value="{{expirationDate}}" class="expiration expiration-user" placeholder="{{expirationDatePlaceholder}}" />' +
' {{#unless isDefaultExpireDateUserEnforced}}' +
' <button class="removeExpiration">Remove</button>' +
' {{/unless}}' +
' </label>' +
' {{/if}}' +
' {{#if isGroupShare}}' +
' <label for="expiration-{{name}}-{{cid}}-{{shareWith}}">Expire share on: ' +
' <input type="text" id="expiration-{{name}}-{{cid}}-{{shareWith}}" value="{{expirationDate}}" class="expiration expiration-group"/>' +
' <label for="expiration-{{name}}-{{cid}}-{{shareWith}}">{{expirationLabel}}: ' +
' <input type="text" id="expiration-{{name}}-{{cid}}-{{shareWith}}" value="{{expirationDate}}" class="expiration expiration-group" placeholder="{{expirationDatePlaceholder}}" />' +
' {{#unless isDefaultExpireDateGroupEnforced}}' +
' <button class="removeExpiration">Remove</button>' +
' {{/unless}}' +
' </label>' +
' {{/if}}' +
' </div>' +
Expand Down Expand Up @@ -116,7 +120,7 @@
/** @type {Function} **/
_template: undefined,

_currentlyToggled: [],
_currentlyToggled: {},

events: {
'click .unshare': 'onUnshare',
Expand Down Expand Up @@ -208,6 +212,10 @@
hasUpdatePermission: this.model.hasUpdatePermission(shareIndex),
hasDeletePermission: this.model.hasDeletePermission(shareIndex),
shareAttributesV1: this.getAttributesObject(shareIndex),
expirationLabel: t('core', 'Expiration'),
expirationDatePlaceholder: t('core', 'Choose an expiration date'),
isDefaultExpireDateUserEnforced: this.configModel.isDefaultExpireDateUserEnforced(),
isDefaultExpireDateGroupEnforced: this.configModel.isDefaultExpireDateGroupEnforced(),
expirationDate: this.model.getExpirationDate(shareIndex),
wasMailSent: this.model.notificationMailWasSent(shareIndex),
shareWith: shareWith,
Expand Down Expand Up @@ -289,14 +297,14 @@
placement: 'bottom'
});

this.$el.find('.expiration-user:not(.hasDatepicker)').each(function(){
this.$el.find('.expiration-user').each(function(){
self._setDatepicker(this, {
maxDate : self.configModel.getDefaultExpireDateUser(),
enforced : self.configModel.isDefaultExpireDateUserEnforced()
});
});

this.$el.find('.expiration-group:not(.hasDatepicker)').each(function(){
this.$el.find('.expiration-group').each(function(){
self._setDatepicker(this, {
maxDate : self.configModel.getDefaultExpireDateGroup(),
enforced : self.configModel.isDefaultExpireDateGroupEnforced()
Expand Down Expand Up @@ -455,7 +463,7 @@
var shareId = $li.data('share-id');

if (!_.isUndefined(this._currentlyToggled[shareId])) {
this._currentlyToggled.splice(shareId, 1);
delete(this._currentlyToggled[shareId]);
this._toggleShareDivs(shareId, false);
} else {
this._currentlyToggled[shareId] = true;
Expand All @@ -465,8 +473,7 @@

_toggleShareDivs: function(shareId, enabled) {
var $li = this.$el.find('li[data-share-id=' + shareId + ']');
$li.children("div").each(function()
{
$li.children("div").each(function() {
var $div = $(this);
if (!$div.hasClass( "avatar" )) {
if (enabled) {
Expand Down
4 changes: 2 additions & 2 deletions core/js/tests/specs/sharedialogexpirationviewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
*/

describe('OC.Share.ShareDialogExpirationView', function() {
describe('OC.Share.ShareDialogLinkExpirationView', function() {
var itemModel;
var fileInfoModel;
var configModel;
Expand Down Expand Up @@ -61,7 +61,7 @@ describe('OC.Share.ShareDialogExpirationView', function() {
expireDate: null,
});

view = new OC.Share.ShareDialogExpirationView({
view = new OC.Share.ShareDialogLinkExpirationView({
model: model,
itemModel: itemModel
});
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Share/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static function registerBackend($itemType, $class, $collectionOf = null,
\OC_Util::addScript('core', 'sharedialoglinkshareview');
\OC_Util::addScript('core', 'sharedialogmailview');
\OC_Util::addScript('core', 'sharedialoglinksocialview');
\OC_Util::addScript('core', 'sharedialogexpirationview');
\OC_Util::addScript('core', 'sharedialoglinkexpirationview');
\OC_Util::addScript('core', 'sharedialogshareelistview');
\OC_Util::addScript('core', 'sharedialogview');
\OC_Util::addScript('core', 'share');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class EditPublicLinkPopup extends OwncloudPage {
'upload' => ".//label[contains(@for, 'sharingDialogAllowPublicUpload')]"
];
private $popupCloseButton = "//a[@class='oc-dialog-close']";
private $expirationDateRequiredErrorMessageXpath = './/*[@id="shareDialogExpirationView"]//span[@class="error-message"]';
private $expirationDateRequiredErrorMessageXpath = './/*[@id="shareDialogLinkExpirationView"]//span[@class="error-message"]';

/**
* sets the NodeElement for the current popup
Expand Down

0 comments on commit 0e4ba37

Please sign in to comment.