idProperty: 'accountId'
});
- var disable = window.lodash.get(this.editDialog.record, 'data.notificationProps', []).length === 0;
+ var notificationProps = window.lodash.get(this.editDialog.record, 'data.notificationProps', []);
+ var disable = notificationProps === null || notificationProps.length === 0;
this.notificationGrid = new Tine.Filemanager.NotificationGridPanel({
store: store,
editDialog: this.editDialog
});
+ var featureEnabled = _.get(Tine.Tinebase.configManager.get('filesystem'), 'enableNotifications', false);
+
+ var disabled = false;
+
+ if (!featureEnabled) {
+ disabled = true;
+ } else if (!_.get(this.editDialog, 'record.data.account_grants.adminGrant', false)) {
+ disabled = true;
+ }
+
this.hasOwnNotificationSettings = new Ext.form.Checkbox({
checked: !disable,
- disabled: !_.get(this.editDialog, 'record.data.account_grants.adminGrant', false) && !disable,
+ disabled: disabled,
boxLabel: this.app.i18n._('This folder has own notification settings'),
listeners: {scope: this, check: this.onOwnNotificationCheck}
});
* @package Filemanager
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
* @author Alexander Stintzing <a.stintzing@metaways.de>
- * @copyright Copyright (c) 2012 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @author Michael Spahn <m.spahn@metaways.de>
+ * @copyright Copyright (c) 2012-2017 Metaways Infosystems GmbH (http://www.metaways.de)
*
*/
*
* @namespace Tine.Filemanager
* @class Tine.Filemanager.SearchCombo
- * @extends Ext.form.ComboBox
+ * @extends Ext.form.TriggerField
*
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
* @author Alexander Stintzing <a.stintzing@metaways.de>
- * @copyright Copyright (c) 2012 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @author Michael Spahn <m.spahn@metaways.de>
+ * @copyright Copyright (c) 2012-2017 Metaways Infosystems GmbH (http://www.metaways.de)
*
* @param {Object} config
* @constructor
* Create a new Tine.Filemanager.SearchCombo
*/
-Tine.Filemanager.SearchCombo = Ext.extend(Tine.Tinebase.widgets.form.RecordPickerComboBox, {
+Tine.Filemanager.SearchCombo = Ext.extend(Ext.form.TriggerField, {
allowBlank: false,
itemSelector: 'div.search-item',
minListWidth: 200,
+
+ app: null,
+
+ recordClass: null,
+ recordProxy: null,
- //private
initComponent: function(){
this.recordClass = Tine.Filemanager.Model.Node;
- this.recordProxy = Tine.Filemanager.recordBackend;
- this.additionalFilters = [
- {field: 'recursive', operator: 'equals', value: true },
- {field: 'path', operator: 'equals', value: '/' }
- ];
- this.initTemplate();
- Tine.Filemanager.SearchCombo.superclass.initComponent.call(this);
- },
-
- /**
- * init template
- * @private
- */
- initTemplate: function() {
- // Custom rendering Template
- // TODO move style def to css ?
- if (! this.tpl) {
- this.tpl = new Ext.XTemplate(
- '<tpl for="."><div class="search-item">',
- '<table cellspacing="0" cellpadding="2" border="0" style="font-size: 11px;" width="100%">',
- '<tr>',
- '<td ext:qtip="{[this.renderPathName(values)]}" style="height:16px">{[this.renderFileName(values)]}</td>',
- '</tr>',
- '</table>',
- '</div></tpl>',
- {
- renderFileName: function(values) {
- return Ext.util.Format.htmlEncode(values.name);
- },
- renderPathName: function(values) {
- return Ext.util.Format.htmlEncode(values.path.replace(values.name, ''));
- }
-
- }
- );
+ this.recordProxy = Tine.Filemanager.fileRecordBackend;
+
+ if (null === this.app) {
+ this.app = Tine.Tinebase.appMgr.get('Filemanager');
}
+
+ this.supr().initComponent.call(this);
+
+ this.addEvents(
+ /**
+ * @param selected node
+ */
+ 'select'
+ );
},
- getValue: function() {
- return Tine.Filemanager.SearchCombo.superclass.getValue.call(this);
- },
+ onTriggerClick: function () {
+ var filepicker = new Tine.Filemanager.FilePickerDialog({
+ title: this.app.i18n._('Select a file'),
+ singleSelect: true,
+ constraint: 'file'
+ });
- setValue: function (value) {
- return Tine.Filemanager.SearchCombo.superclass.setValue.call(this, value);
- }
+ filepicker.on('selected', function (node) {
+ if (!node || 0 === node.length) {
+ return true;
+ }
+ this.fireEvent('select', node[0]);
+ this.setValue(node[0].path);
+
+ }, this);
+
+ filepicker.openWindow();
+ }
});
Tine.widgets.form.RecordPickerManager.register('Filemanager', 'Node', Tine.Filemanager.SearchCombo);
/**
* is called when selecting a record in the searchCombo (relationpickercombo)
*/
- onAddRecordFromCombo: function() {
- var record = this.getActiveSearchCombo().store.getById(this.getActiveSearchCombo().getValue());
-
+ onAddRecordFromCombo: function(node) {
+ var record = null;
+
+ if (this.getActiveSearchCombo().hasOwnProperty('store')) {
+ record = this.getActiveSearchCombo().store.getById(this.getActiveSearchCombo().getValue())
+ } else {
+ record = node;
+ }
+
if (! record) {
return;
}
}
this.onAddRecord(record, relconf);
-
- this.getActiveSearchCombo().collapse();
- this.getActiveSearchCombo().reset();
+
+ if (this.getActiveSearchCombo().hasOwnProperty('collapse')) {
+ this.getActiveSearchCombo().collapse();
+ this.getActiveSearchCombo().reset();
+ }
},
/**
* call to add relation from an external component
- *
+ *
+ * @todo refactor this trash
+ *
* @param {Tine.Tinebase.data.Record} record
* @param {Object} relconf
*/
if (! relconf) {
relconf = {};
}
- if (record.data.hasOwnProperty('relations')) {
+ if (record.data && record.data.hasOwnProperty('relations')) {
record.data.relations = null;
delete record.data.relations;
}
var rc = this.getActiveSearchCombo().recordClass;
var relatedPhpModel = rc.getPhpClassName();
-
+
var app = rc.getMeta('appName'), model = rc.getMeta('modelName'), f = app + model;
var type = '';
-
+
if (this.constraintsConfig[f] && this.constraintsConfig[f].length) {
// per default the first defined type is used
var type = this.constraintsConfig[f][0].type;
type = '';
var relationRecord = new Tine.Tinebase.Model.Relation(Ext.apply(this.getRelationDefaults(), Ext.apply({
- related_record: record.data,
+ related_record: record.data || record,
related_id: record.id,
related_model: relatedPhpModel,
type: type,
this.onAddNewRelationToStore(relationRecord, record);
}
}
-
- // reset search combo
- this.getActiveSearchCombo().collapse();
- this.getActiveSearchCombo().reset();
},
/**
var relatedApp = Tine.Tinebase.appMgr.get(appName);
var relatedConstrainsConfig = relatedApp.getRegistry().get('relatableModels');
var ownRecordClassName = this.editDialog.recordClass.getMeta('modelName');
- var relatedRecordProxy = Tine[appName][(model.toLowerCase() + 'Backend')];
+ var relatedRecordProxy = this.getActiveSearchCombo().recordProxy || Tine[appName][(model.toLowerCase() + 'Backend')];
if (! Ext.isFunction(record.get)) {
record = relatedRecordProxy.recordReader({responseText: Ext.encode(record)});
* @param {Tine.Tinebase.data.Record} record
*/
onAddNewRelationToStore: function(relationRecord, record) {
- relationRecord.data.related_record.relations = null;
- delete relationRecord.data.related_record.relations;
-
+ var _ = window.lodash;
+
+ if (_.get(relationRecord, 'data.related_record.relations', false)) {
+ relationRecord.data.related_record.relations = null;
+ delete relationRecord.data.related_record.relations;
+ }
+
if (this.relationCheck(relationRecord)) {
Tine.log.debug('Adding new relation:');
Tine.log.debug(relationRecord);