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

Commit

Permalink
feature(Filemanager): inherit props from Tree_Node
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliusweiss committed Jun 27, 2022
1 parent 9589b55 commit 9fa6d11
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/tine20/Tinebase/Frontend/JsonTest.php
Expand Up @@ -643,7 +643,7 @@ public function testGetAllRegistryData()
self::assertTrue(is_bool($changepwValue), 'changepw should be (bool) false: ' . var_export($changepwValue, TRUE));

$userApps = $registryData['Tinebase']['userApplications'];
self::assertEquals('Admin', $userApps[0]['name'], 'first app should be Admin: ' . print_r($userApps, TRUE));
self::assertEquals('Tinebase', $userApps[0]['name'], 'first app should be Tinebase: ' . print_r($userApps, TRUE));

$locale = Tinebase_Core::getLocale();
$symbols = Zend_Locale::getTranslationList('symbols', $locale);
Expand Down
22 changes: 19 additions & 3 deletions tine20/Filemanager/js/Model.js
Expand Up @@ -37,12 +37,28 @@ Tine.Filemanager.Model.NodeMixin = {
return [Tine.Tinebase.common.getUrl().replace(/\/$/, ''), '#',
Tine.Tinebase.appMgr.get('Filemanager').getRoute(this.get('path'), this.get('type'))].join('/');
},


mixinConfig: {
before: {
create(o, meta) {
// NOTE: custom fields of Tree_Nodes are inherited but mc can't show it
const parentConfig = Tine.Tinebase.Model.Tree_Node.getModelConfiguration();
_.difference(parentConfig.fieldKeys, meta.modelConfiguration.fieldKeys).forEach((fieldName) => {
const idx = parentConfig.fieldKeys.indexOf(fieldName);
meta.modelConfiguration.fieldKeys.splice(idx, 0, fieldName);
o.splice(idx, 0, {... Tine.Tinebase.Model.Tree_Node.getField(fieldName)});
meta.modelConfiguration.fields[fieldName] = {... parentConfig.fields[fieldName]};
})
// @TODO: filtermodel?
}
}
},

statics: {
type(path) {
path = String(path);
const basename = path.split('/').pop(); // do not use basename() here -> recursion!
return path.lastIndexOf('/') === --path.length || basename.lastIndexOf('.') < Math.max(1, basename.length - 5) ? 'folder' : 'file';
return path.lastIndexOf('/') === path.length-1 || basename.lastIndexOf('.') < Math.max(1, basename.length - 5) ? 'folder' : 'file';
},

dirname(path) {
Expand Down Expand Up @@ -77,7 +93,7 @@ Tine.Filemanager.Model.NodeMixin = {
sanitize(path) {
path = String(path);
const self = Tine.Filemanager.Model.Node;
let isFolder = path.lastIndexOf('/') === --path.length;
let isFolder = path.lastIndexOf('/') === path.length -1;
path = _.compact(path.split('/')).join('/');
return '/' + path + (isFolder || self.type(path) === 'folder' ? '/' : '');
},
Expand Down
12 changes: 12 additions & 0 deletions tine20/Tinebase/Setup/Update/15.php
Expand Up @@ -27,6 +27,7 @@ class Tinebase_Setup_Update_15 extends Setup_Update_Abstract
const RELEASE015_UPDATE011 = __CLASS__ . '::update011';
const RELEASE015_UPDATE012 = __CLASS__ . '::update012';
const RELEASE015_UPDATE013 = __CLASS__ . '::update013';
const RELEASE015_UPDATE014 = __CLASS__ . '::update014';

static protected $_allUpdates = [
self::PRIO_TINEBASE_STRUCTURE => [
Expand Down Expand Up @@ -79,6 +80,10 @@ class Tinebase_Setup_Update_15 extends Setup_Update_Abstract
self::CLASS_CONST => self::class,
self::FUNCTION_CONST => 'update013',
],
self::RELEASE015_UPDATE014 => [
self::CLASS_CONST => self::class,
self::FUNCTION_CONST => 'update014',
],
],
self::PRIO_TINEBASE_UPDATE => [
self::RELEASE015_UPDATE000 => [
Expand Down Expand Up @@ -282,4 +287,11 @@ public function update013()

$this->addApplicationUpdate(Tinebase_Config::APP_NAME, '15.13', self::RELEASE015_UPDATE013);
}
public function update014()
{
$app = Tinebase_Application::getInstance()->getApplicationByName('Tinebase');
$app->order = 0;
$app = Tinebase_Application::getInstance()->updateApplication($app);
$this->addApplicationUpdate(Tinebase_Config::APP_NAME, '15.14', self::RELEASE015_UPDATE014);
}
}
3 changes: 2 additions & 1 deletion tine20/Tinebase/Setup/setup.xml
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<application>
<name>Tinebase</name>
<version>15.13</version>
<version>15.14</version>
<order>0</order>
<minimumRequiredVersion>12.28</minimumRequiredVersion>
<tables>
<table>
Expand Down

0 comments on commit 9fa6d11

Please sign in to comment.