Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
fix(Tinebase/js): add expire date field for data publish action
Browse files Browse the repository at this point in the history
  • Loading branch information
ccheng-dev committed Mar 20, 2023
1 parent 89cf752 commit 87f93c5
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 20 deletions.
14 changes: 13 additions & 1 deletion tine20/Filemanager/Config.php
Expand Up @@ -17,6 +17,7 @@ class Filemanager_Config extends Tinebase_Config_Abstract
{
const APP_NAME = 'Filemanager';
const PUBLIC_DOWNLOAD_URL = 'publicDownloadUrl';
const PUBLIC_DOWNLOAD_DEFAULT_VALID_TIME = 'publicDownloadDefaultValidTime';

/**
* (non-PHPdoc)
Expand All @@ -32,7 +33,18 @@ class Filemanager_Config extends Tinebase_Config_Abstract
'clientRegistryInclude' => true,
'setByAdminModule' => false,
'setBySetupModule' => true,
)
),
self::PUBLIC_DOWNLOAD_DEFAULT_VALID_TIME => [
//_('Public Download Default Valid Time')
'label' => 'Public Download Default Valid Time',
//_('Public download fefault valid time, unit is day')
'description' => 'Public Download Default Valid Time, unit is day',
self::TYPE => self::TYPE_INT,
self::DEFAULT_STR => 30, // 30 days
self::CLIENTREGISTRYINCLUDE => true,
self::SETBYADMINMODULE => true,
self::SETBYSETUPMODULE => true,
]
);

/**
Expand Down
2 changes: 1 addition & 1 deletion tine20/Filemanager/js/DownloadLinkGridPanel.js
Expand Up @@ -290,7 +290,7 @@ Tine.Filemanager.DownloadLinkGridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
hidden: true
}, {
id: 'expiry_time',
header: this.app.i18n._("Expiration Time"),
header: this.app.i18n._("Valid until"),
width: 100,
sortable: true,
dataIndex: 'expiry_time',
Expand Down
35 changes: 19 additions & 16 deletions tine20/Filemanager/js/nodeActions.js
Expand Up @@ -538,28 +538,31 @@ Tine.Filemanager.nodeActions.Publish = {
iconCls: 'action_publish',
scope: this,
handler: function() {
var app = this.initialConfig.app,
i18n = app.i18n,
selected = _.get(this, 'initialConfig.selections[0]') ||_.get(this, 'initialConfig.filteredContainer');

if (! selected) {
return;
}

var passwordDialog = new Tine.Tinebase.widgets.dialog.PasswordDialog({
const app = this.initialConfig.app;
const selected = _.get(this, 'initialConfig.selections[0]') || _.get(this, 'initialConfig.filteredContainer');
if (! selected) return;

const date = new Date();
const defaultValidDate = Tine.Tinebase.configManager.get('publicDownloadDefaultValidTime', 'Filemanager') ?? 30;
date.setDate(date.getDate() + defaultValidDate);

this.validDateField = new Ext.form.DateField({
fieldLabel: app.i18n._('Valid until'),
value: date
});

const passwordDialog = new Tine.Tinebase.widgets.dialog.PasswordDialog({
allowEmptyPassword: true,
locked: false,
questionText: i18n._('Download links can be protected with a password. If no password is specified, anyone who knows the link can access the selected files.')
questionText: app.i18n._('Download links can be protected with a password. If no password is specified, anyone who knows the link can access the selected files.'),
additionalFields: [this.validDateField]
});

passwordDialog.openWindow();

passwordDialog.on('apply', function (password) {
var date = new Date();
date.setDate(date.getDate() + 30);

var record = new Tine.Filemanager.Model.DownloadLink({
const record = new Tine.Filemanager.Model.DownloadLink({
node_id: selected.id,
expiry_time: date,
expiry_time: this.validDateField.value,
password: password
});

Expand Down
7 changes: 5 additions & 2 deletions tine20/Tinebase/js/widgets/dialog/PasswordDialog.js
Expand Up @@ -53,6 +53,8 @@ Tine.Tinebase.widgets.dialog.PasswordDialog = Ext.extend(Tine.Tinebase.dialog.Di

layout: 'fit',
border: false,

additionalFields: [],


/**
Expand Down Expand Up @@ -92,7 +94,7 @@ Tine.Tinebase.widgets.dialog.PasswordDialog = Ext.extend(Tine.Tinebase.dialog.Di
keyup: this.onChange,
keydown: this.onKeyDown
}
}]
}], this.additionalFields
]
}]
}];
Expand Down Expand Up @@ -194,7 +196,8 @@ Tine.Tinebase.widgets.dialog.PasswordDialog = Ext.extend(Tine.Tinebase.dialog.Di
width: 400,
height: 130 +
(this.hasPwGen ? 20 : 0) +
(Math.ceil(this.questionText.length/70) * 20),
(Math.ceil(this.questionText.length/70) * 20) +
this.additionalFields.length * 30,
layout: 'fit',
items: this
}, config));
Expand Down
2 changes: 2 additions & 0 deletions tine20/library/ExtJS/src/widgets/form/DateField.js
Expand Up @@ -263,6 +263,8 @@ disabledDates: ["^03"]
this.markInvalid(String.format(this.disabledDatesText, fvalue));
return false;
}

this.fullDateTime = value;
return true;
},

Expand Down

0 comments on commit 87f93c5

Please sign in to comment.