/*
* Copyright 2017 Anyware Services
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Model for node of hierarchical simple contents tree.
* @private
*/
Ext.define('Ametys.plugins.cms.content.tree.HierarchicalReferenceTablesTree.HierarchicalReferenceTablesTreeEntry', {
extend: 'Ext.data.Model',
fields : [
{name: 'text', mapping: 'title', type: 'string'},
'contentId',
'lang',
{name: 'leaf', type: 'boolean'},
{name: 'isSimple', type: 'boolean'},
{name: 'isCandidate', type: 'boolean', defaultValue: false},
{name: 'disabled', type:'boolean', defaultValue: false},
'contenttypesIds',
'name',
'title',
'iconGlyph',
'iconDecorator',
'iconSmall',
'iconMedium',
'iconLarge',
'type',
{
name: 'data-qtipTitle',
depends: ['title'],
calculate: function(data) { return data.title }
},
{
name: 'data-qtipIcon',
depends: ['iconGlyph', 'iconDecorator', 'isCandidate'],
calculate: function (data)
{
if (data.isCandidate)
{
return 'ametysicon-star129';
}
else
{
return Ext.isEmpty(data.iconGlyph) ? null : data.iconGlyph + (Ext.isEmpty(data.iconDecorator) ? '' : ' ' + data.iconDecorator);
}
}
},
'tooltip',
{
name: 'icon',
depends: ['iconGlyph', 'iconDecorator', 'iconSmall'],
calculate: function (data)
{
return Ext.isEmpty(data.iconGlyph) && !Ext.isEmpty(data.iconSmall) ? Ametys.CONTEXT_PATH + data.iconSmall : null;
}
},
{
name: 'iconCls',
depends: ['iconGlyph', 'iconDecorator', 'isCandidate'],
calculate: function (data)
{
if (data.isCandidate)
{
return 'ametysicon-star129';
}
else
{
return Ext.isEmpty(data.iconGlyph) ? null : data.iconGlyph + (Ext.isEmpty(data.iconDecorator) ? '' : ' ' + data.iconDecorator);
}
}
},
{
name: 'cls',
convert: function (value, node)
{
value = value || "";
if (node.get('contentId') == 'rootCandidate')
{
value += " root-candidate"
}
return Ext.String.trim(value + (node.get('disabled') ? ' disabled' : ''));
}
}
]
});