* Resources: Customfields can now be per category

This commit is contained in:
nathan 2022-11-16 14:10:34 -07:00
parent 85ded6f1fc
commit bfb335f7c3
6 changed files with 139 additions and 57 deletions

View File

@ -430,7 +430,10 @@ class admin_customfields
$test = new Etemplate();
if($test->read($this->appname.'.admin.types')) $this->manage_content_types = true;
$this->tmpl = new Etemplate();
if(is_null($this->tmpl))
{
$this->tmpl = new Etemplate();
}
$this->tmpl->read('admin.customfield_edit');
Api\Translation::add_app('infolog'); // til we move the translations
@ -501,13 +504,14 @@ class admin_customfields
}
$content['statustext'] = $content['options'][$content['cf_type']];
$content['attributes'] = self::$type_attribute_flags;
$exec = static::class == 'admin_customfields' ? 'admin.admin_customfields.edit' : $this->appname . '.' . static::class . '.edit';
$this->tmpl->exec('admin.admin_customfields.edit',$content,$sel_options,$readonlys,array(
'cf_id' => $cf_id,
'cf_app' => $this->appname,
'cf_name' => $content['cf_name'],
$this->tmpl->exec($exec, $content, $sel_options, $readonlys, array(
'cf_id' => $cf_id,
'cf_app' => $this->appname,
'cf_name' => $content['cf_name'],
'use_private' => $this->use_private,
),2);
), 2);
}
/**

View File

@ -15,13 +15,11 @@
<rows>
<row>
<hbox>
<description id="appname"/>
<description value=" - "/>
<description value="type"/>
<description id="appname"/>
<description value="-"/>
<description value="type"/>
</hbox>
<menulist>
<menupopup id="types" no_lang="1" onchange="1"/>
</menulist>
<select id="types" no_lang="1" onchange="1"/>
<button label="Delete" id="delete" onclick="app.admin.cf_type_delete"/>
<textbox blur="new name" id="name"/>
<button label="Create" id="create"/>
@ -60,28 +58,27 @@
<nextmatch-sortheader label="Last modified" id="cf_modified"/>
</row>
<row class="row" valign="top">
<menulist>
<menupopup id="${row}[cf_type2]" no_lang="1" multiple="true" empty_label="All"/>
</menulist>
<description id="${row}[cf_name]" no_lang="1" />
<vbox>
<description id="${row}[cf_label]" no_lang="1"/>
<description id="${row}[cf_label]"/>
</vbox>
<customfields-types statustext="Type of customfield" id="{$row}[cf_type]"/>
<checkbox id="${row}[cf_needed]" selected_value="1" unselected_value="0"/>
<select-account id="${row}[cf_private]" account_type="both"/>
<description id="${row}[cf_values]" no_lang="1" class="values"/>
<vbox>
<description id="${row}[cf_len]" no_lang="1"/>
<description id="${row}[cf_rows]" no_lang="1"/>
</vbox>
<description id="${row}[cf_order]" no_lang="1"/>
<vbox>
<date-time id="${row}[cf_modified]"/>
<select-account id="${row}[cf_modifier]"/>
</vbox>
</row>
<select id="${row}[cf_type2]" no_lang="1" multiple="true" empty_label="All" readonly="true"/>
<description id="${row}[cf_name]" no_lang="1"/>
<vbox>
<description id="${row}[cf_label]" no_lang="1"/>
<description id="${row}[cf_label]"/>
</vbox>
<customfields-types statustext="Type of customfield" id="{$row}[cf_type]" readonly="true"
app="$cont[appname]"/>
<checkbox id="${row}[cf_needed]" selected_value="1" unselected_value="0" readonly="true"/>
<select-account id="${row}[cf_private]" account_type="both" readonly="true"/>
<description id="${row}[cf_values]" no_lang="1" class="values"/>
<vbox>
<description id="${row}[cf_len]" no_lang="1"/>
<description id="${row}[cf_rows]" no_lang="1"/>
</vbox>
<description id="${row}[cf_order]" no_lang="1"/>
<vbox>
<date-time id="${row}[cf_modified]" readonly="true"/>
<select-account id="${row}[cf_modifier]" readonly="true"/>
</vbox>
</row>
</rows>
</grid>
</template>
@ -92,4 +89,4 @@
<template id="@type_template"/>
<nextmatch id="nm" template="admin.customfields.fields" header_left="admin.customfields.add"/>
</template>
</overlay>
</overlay>

View File

@ -0,0 +1,59 @@
<?php
/**
* Resources - Custom fields
*
* @link http://www.egroupware.org
* @author Nathan Gray
* @package resources
* @copyright (c) 2022 by Nathan Gray
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Etemplate;
use EGroupware\Api\Acl;
/**
* Administration of custom fields, type and status
*
* Extending to use categories as type for custom fields
*/
class resources_customfields extends admin_customfields
{
public $appname = 'resources';
/**
* Instance of the resources BO class
*
* @var resources_bo
*/
var $bo;
function __construct()
{
parent::__construct('resources');
$this->bo = new resources_bo();
$this->tmpl = new Etemplate();
// For index - override so "add" button opens correctly
$this->tmpl->setElementAttribute("nm", "header_left", "resources.customfields.add");
$content_types = $this->bo->acl->get_cats(Acl::ADD);
array_walk($content_types, function ($name, $id)
{
$this->content_types[$id] = array('name' => $name);
});
Api\Translation::add_app('resources');
}
public function edit($content = null)
{
// Turn private off
$_GET['use_private'] = false;
unset($content['use_private']);
parent::edit($content);
}
}

View File

@ -52,18 +52,22 @@ class resources_hooks
if ($GLOBALS['egw_info']['user']['apps']['admin'])
{
$file = Array(
'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname=' . $appname.'&ajax=true'),
'Global Categories' => Egw::link('/index.php',array(
'menuaction' => 'admin.admin_categories.index',
'appname' => $appname,
'global_cats'=> true,
'ajax' => 'true'
$file = array(
'Site Configuration' => Egw::link('/index.php', 'menuaction=admin.admin_config.index&appname=' . $appname . '&ajax=true'),
'Global Categories' => Egw::link('/index.php', array(
'menuaction' => 'admin.admin_categories.index',
'appname' => $appname,
'global_cats' => true,
'ajax' => 'true'
)),
'Configure Access Permissions' => Egw::link('/index.php',
'menuaction=resources.resources_acl_ui.index&ajax=true'),
'Custom Fields'=>egw::link('/index.php',
'menuaction=admin.admin_customfields.index&appname=resources&ajax=true'),
'Configure Access Permissions' => Egw::link(
'/index.php',
'menuaction=resources.resources_acl_ui.index&ajax=true'
),
'Custom Fields' => egw::link(
'/index.php',
'menuaction=resources.resources_customfields.index&appname=resources&ajax=true'
),
);
if ($location == 'admin')
{

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE overlay PUBLIC "-//EGroupware GmbH//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
<!-- $Id$ -->
<overlay>
<template id="resources.customfields.types">
</template>
<template id="resources.customfields.add" template="" lang="" group="0" version="1.9.001">
<buttononly label="Add" id="add"
onclick="egw.open_link('resources.resources_customfields.edit&amp;appname='+widget.getArrayMgr('content').getRoot().getEntry('nm[appname]'),false,'450x380');"/>
</template>
<template id="resources.admin.types" template="" lang="" group="0" version="">
<template id="resources.customfields.types" content="content_types"/>
<styles>.header{
font-weight: bold;
}
</styles>
</template>
</overlay>

View File

@ -113,7 +113,7 @@
<description value="Custom fields"/>
</row>
<row valign="top">
<customfields/>
<customfields type_filter="@cat_id"/>
</row>
</rows>
</grid>
@ -141,16 +141,16 @@
<appicon/>
<description/>
</row>
<row class="dialogHeader2">
<description value="Quantity"/>
<textbox statustext="Quantity of resource" id="quantity" size="5" maxlength="10" class="et2_fullWidth"/>
<description/>
<description value="Category"/>
<menulist span="3">
<menupopup align="right" statustext="Which category does this resource belong to?" id="cat_id" needed="1" no_lang="1" class="et2_fullWidth" />
</menulist>
<description/>
</row>
<row class="dialogHeader2">
<description value="Quantity"/>
<textbox statustext="Quantity of resource" id="quantity" size="5" maxlength="10"
class="et2_fullWidth"/>
<description/>
<description value="Category"/>
<select span="3" tatustext="Which category does this resource belong to?" id="cat_id"
needed="1" no_lang="1" onchange="1" class="et2_fullWidth"/>
<description/>
</row>
<row class="dialogHeader3">
<description value="Useable"/>
<textbox statustext="How many of them are useable?" id="useable" size="5" maxlength="10" class="et2_fullWidth"/>