Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:collectiveaccess/providence into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
collectiveaccess committed Apr 29, 2022
2 parents eabd4f0 + 669b367 commit bd61ef4
Show file tree
Hide file tree
Showing 17 changed files with 122 additions and 62 deletions.
14 changes: 14 additions & 0 deletions app/conf/app.conf
Expand Up @@ -1924,6 +1924,20 @@ always_show_bundle_preview_for_attributes = 0
# placement.
always_show_counts_for_relationship_bundles_in_editor = 0


# Default editor preferences - used when user has not selected as default in
# their account-specific preferences. Can be set on a per-table basis in the form
# <table>_default_editor (cataloguing editor)
# <table>_quickadd_editor (quickadd editor)
# <table>_batch_editor (batch editor)
#
# Defaults can also be set on the table/type-specific basis using the form:
# <table>_<type>_default_editor
#ca_list_items_default_editor =
#ca_list_items_default_quickadd_editor =
#ca_list_items_default_batch_editor =


# -----------------------------------
# Default type to use when creating sets
# (in search results "sets" options, for example)
Expand Down
9 changes: 8 additions & 1 deletion app/conf/user_pref_defs.conf
Expand Up @@ -69,7 +69,7 @@ preferenceGroups = {
quickadd_ca_occurrences_editor_ui = {},
quickadd_ca_collections_editor_ui = {},
quickadd_ca_storage_locations_editor_ui = {},
#quickadd_ca_list_items_editor_ui = {},
quickadd_ca_list_items_editor_ui = {},
}
},
units = {
Expand Down Expand Up @@ -523,6 +523,13 @@ preferenceDefinitions = {
displayType = DT_SELECT,
default =
},
quickadd_ca_list_items_editor_ui = {
label = _("List item editor user interface"),
description = _("Selects which user interface to use when quick-adding list items."),
formatType = FT_LIST_ITEM_EDITOR_UI,
displayType = DT_SELECT,
default =
},

#
# Units of measurement
Expand Down
2 changes: 1 addition & 1 deletion app/lib/BundlableLabelableBaseModelWithAttributes.php
Expand Up @@ -2676,7 +2676,7 @@ public function getBundleFormHTMLForScreen($pm_screen, $pa_options, &$pa_placeme
if (isset($pa_options['ui_instance']) && ($pa_options['ui_instance'])) {
$t_ui = $pa_options['ui_instance'];
} else {
$t_ui = ca_editor_uis::loadDefaultUI($vs_table_name, $pa_options['request'], $this->getTypeID());
$t_ui = ca_editor_uis::loadDefaultUI($vs_table_name, $pa_options['request'], $this->getTypeID(), ['editorPref' => caGetOption('quickadd', $pa_options, false) ? 'quickadd' : null]);
}
if (!$t_ui) { return false; }

Expand Down
15 changes: 11 additions & 4 deletions app/models/ca_editor_uis.php
Expand Up @@ -333,6 +333,7 @@ static public function loadDefaultUI($pm_table_name_or_num, $po_request, $pn_typ
$va_uis_by_type = $po_request->user->getPreference("cataloguing_{$vs_table_name}_editor_ui");
break;
}

$va_available_uis_by_type = $po_request->user->_getUIListByType($vn_table_num);
} else {
$va_uis_by_type = $va_available_uis_by_type = [];
Expand All @@ -345,13 +346,19 @@ static public function loadDefaultUI($pm_table_name_or_num, $po_request, $pn_typ
$vn_type_id = null;
}
$va_uis_by_type = [];
} else {
if (!isset($va_available_uis_by_type[$vn_type_id][$va_uis_by_type[$vn_type_id]]) && !isset($va_available_uis_by_type['__all__'][$va_uis_by_type[$vn_type_id]])) {
$vn_type_id = null;
}
} elseif (!isset($va_available_uis_by_type[$vn_type_id][$va_uis_by_type[$vn_type_id]]) && !isset($va_available_uis_by_type['__all__'][$va_uis_by_type[$vn_type_id]])) {
$vn_type_id = null;
}
}

if($vn_type_id && isset($va_uis_by_type[$vn_type_id])) {
if ($t_ui = ca_editor_uis::findAsInstance(['ui_id' => $va_uis_by_type[$vn_type_id]])) { return $t_ui; }
}
if(isset($va_uis_by_type['__all__'])) {
if ($t_ui = ca_editor_uis::findAsInstance(['ui_id' => $va_uis_by_type['__all__']])) { return $t_ui; }
}


$t_ui = new ca_editor_uis();

// If table supports null types take type_id=null to be "none" rather than a signal to allow any type of editor
Expand Down
23 changes: 22 additions & 1 deletion app/models/ca_users.php
Expand Up @@ -1608,7 +1608,6 @@ public function getPreference($ps_pref) {
}
return $this->getPreferenceDefault($ps_pref);
} else {
//$this->postError(920, _t("%1 is not a valid user preference", $ps_pref),"User->getPreference()");
return null;
}
}
Expand Down Expand Up @@ -1653,11 +1652,33 @@ public function getPreferenceDefault($ps_pref, $pa_options=null) {
$vn_table_num = $this->_editorPrefFormatTypeToTableNum($va_pref_info["formatType"]);
$va_uis = $this->_getUIListByType($vn_table_num);

$table = Datamodel::getTableName($vn_table_num);
$config = Configuration::load();
$va_defaults = array();
if(is_array($va_uis)) {
foreach($va_uis as $vn_type_id => $va_editor_info) {
$type_code = caGetListItemIdno($vn_type_idno);
foreach($va_editor_info as $vn_ui_id => $va_editor_labels) {
if(preg_match('!^batch_.*_ui$!', $ps_pref)) {
if((($dp = $config->get("{$table}_{$type_code}_default_batch_editor")) || ($dp = $config->get("{$table}_default_batch_editor"))) && ($d_ui_id = ca_editor_uis::find(['editor_code' => $dp], ['returnAs' => 'firstId']))) {
$va_defaults[$vn_type_id] = $d_ui_id;
break;
}
}
if(preg_match('!^quickadd_.*_ui$!', $ps_pref)) {
if((($dp = $config->get("{$table}_{$type_code}_default_quickadd_editor")) || ($dp = $config->get("{$table}_default_quickadd_editor"))) && ($d_ui_id = ca_editor_uis::find(['editor_code' => $dp], ['returnAs' => 'firstId']))) {
$va_defaults[$vn_type_id] = $d_ui_id;
break;
}
}
if(preg_match('!^cataloguing_.*_ui$!', $ps_pref)) {
if((($dp = $config->get("{$table}_{$type_code}_default_editor")) || ($dp = $config->get("{$table}_default_editor")))&& ($d_ui_id = ca_editor_uis::find(['editor_code' => $dp], ['returnAs' => 'firstId']))) {
$va_defaults[$vn_type_id] = $d_ui_id;
break;
}
}
$va_defaults[$vn_type_id] = $vn_ui_id;
break;
}
}
}
Expand Down
Expand Up @@ -70,7 +70,7 @@

<div class="quickAddFormTopPadding"><!-- empty --></div>
<div class="quickAddErrorContainer" id="<?= $vs_form_name; ?>Errors<?= $vs_field_name_prefix.$vs_n; ?>"> </div>
<div class="quickAddSectionBox" id="{$vs_form_name}Container<?= $vs_field_name_prefix.$vs_n; ?>">
<div class="quickAddSectionBox" id="<?= $vs_form_name.'Container'.$vs_field_name_prefix.$vs_n; ?>">
<?php
// Output hierarchy browser
$va_lookup_urls = caJSONLookupServiceUrl($this->request, 'ca_list_items');
Expand Down Expand Up @@ -134,7 +134,8 @@
'restrictToTypes' => array($t_subject->get('type_id')),
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel'), // force query text to be default in label fields
'omit' => ['parent_id', 'hierarchy_location', 'hierarchy_navigation']
'omit' => ['parent_id', 'hierarchy_location', 'hierarchy_navigation'],
'quickadd'=> true
));

print join("\n", $va_form_elements);
Expand Down
5 changes: 3 additions & 2 deletions themes/default/views/editor/collections/quickadd_html.php
Expand Up @@ -69,13 +69,14 @@

<div class="quickAddFormTopPadding"><!-- empty --></div>
<div class="quickAddErrorContainer" id="<?= $vs_form_name; ?>Errors<?= $vs_field_name_prefix.$vs_n; ?>"> </div>
<div class="quickAddSectionBox" id="{$vs_form_name}Container<?= $vs_field_name_prefix.$vs_n; ?>">
<div class="quickAddSectionBox" id="<?= $vs_form_name.'Container'.$vs_field_name_prefix.$vs_n; ?>">
<?php
$va_form_elements = $t_subject->getBundleFormHTMLForScreen($this->getVar('screen'), array(
'request' => $this->request,
'restrictToTypes' => array($t_subject->get('type_id')),
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel') // force query text to be default in label fields
'forceLabelForNew' => $this->getVar('forceLabel'), // force query text to be default in label fields
'quickadd' => true
));

print join("\n", $va_form_elements);
Expand Down
11 changes: 6 additions & 5 deletions themes/default/views/editor/entities/quickadd_html.php
Expand Up @@ -69,13 +69,14 @@

<div class="quickAddFormTopPadding"><!-- empty --></div>
<div class="quickAddErrorContainer" id="<?= $vs_form_name; ?>Errors<?= $vs_field_name_prefix.$vs_n; ?>"> </div>
<div class="quickAddSectionBox" id="{$vs_form_name}Container<?= $vs_field_name_prefix.$vs_n; ?>">
<div class="quickAddSectionBox" id="<?= $vs_form_name.'Container'.$vs_field_name_prefix.$vs_n; ?>">
<?php
$va_form_elements = $t_subject->getBundleFormHTMLForScreen($this->getVar('screen'), array(
'request' => $this->request,
'restrictToTypes' => array($t_subject->get('type_id')),
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel') // force query text to be default in label fields
'request' => $this->request,
'restrictToTypes' => array($t_subject->get('type_id')),
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel'), // force query text to be default in label fields
'quickadd' => true
));

print join("\n", $va_form_elements);
Expand Down
11 changes: 6 additions & 5 deletions themes/default/views/editor/loans/quickadd_html.php
Expand Up @@ -69,13 +69,14 @@

<div class="quickAddFormTopPadding"><!-- empty --></div>
<div class="quickAddErrorContainer" id="<?= $vs_form_name; ?>Errors<?= $vs_field_name_prefix.$vs_n; ?>"> </div>
<div class="quickAddSectionBox" id="{$vs_form_name}Container<?= $vs_field_name_prefix.$vs_n; ?>">
<div class="quickAddSectionBox" id="<?= $vs_form_name.'Container'.$vs_field_name_prefix.$vs_n; ?>">
<?php
$va_form_elements = $t_subject->getBundleFormHTMLForScreen($this->getVar('screen'), array(
'request' => $this->request,
'restrictToTypes' => array($t_subject->get('type_id')),
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel') // force query text to be default in label fields
'request' => $this->request,
'restrictToTypes' => array($t_subject->get('type_id')),
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel'), // force query text to be default in label fields
'quickadd' => true
));

print join("\n", $va_form_elements);
Expand Down
13 changes: 7 additions & 6 deletions themes/default/views/editor/movements/quickadd_html.php
Expand Up @@ -69,14 +69,15 @@

<div class="quickAddFormTopPadding"><!-- empty --></div>
<div class="quickAddErrorContainer" id="<?= $vs_form_name; ?>Errors<?= $vs_field_name_prefix.$vs_n; ?>"> </div>
<div class="quickAddSectionBox" id="{$vs_form_name}Container<?= $vs_field_name_prefix.$vs_n; ?>">
<div class="quickAddSectionBox" id="Container<?= $vs_form_name.'Container'.$vs_field_name_prefix.$vs_n; ?>">
<?php
$va_form_elements = $t_subject->getBundleFormHTMLForScreen($this->getVar('screen'), array(
'request' => $this->request,
'restrictToTypes' => array($t_subject->get('type_id')),
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel'), // force query text to be default in label fields
'policy' => $this->request->getParameter('usePolicy', pString)
'request' => $this->request,
'restrictToTypes' => array($t_subject->get('type_id')),
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel'), // force query text to be default in label fields
'policy' => $this->request->getParameter('usePolicy', pString),
'quickadd' => true
));

print join("\n", $va_form_elements);
Expand Down
11 changes: 6 additions & 5 deletions themes/default/views/editor/object_lots/quickadd_html.php
Expand Up @@ -70,13 +70,14 @@

<div class="quickAddFormTopPadding"><!-- empty --></div>
<div class="quickAddErrorContainer" id="<?= $vs_form_name; ?>Errors<?= $vs_field_name_prefix.$vs_n; ?>"> </div>
<div class="quickAddSectionBox" id="{$vs_form_name}Container<?= $vs_field_name_prefix.$vs_n; ?>">
<div class="quickAddSectionBox" id="Container<?= $vs_form_name.'Container'.$vs_field_name_prefix.$vs_n; ?>">
<?php
$va_form_elements = $t_subject->getBundleFormHTMLForScreen($this->getVar('screen'), array(
'request' => $this->request,
'restrictToTypes' => array($t_subject->get('type_id')),
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel') // force query text to be default in label fields
'request' => $this->request,
'restrictToTypes' => array($t_subject->get('type_id')),
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel'), // force query text to be default in label fields
'quickadd' => true
));

print join("\n", $va_form_elements);
Expand Down
11 changes: 6 additions & 5 deletions themes/default/views/editor/objects/quickadd_html.php
Expand Up @@ -69,13 +69,14 @@

<div class="quickAddFormTopPadding"><!-- empty --></div>
<div class="quickAddErrorContainer" id="<?= $vs_form_name; ?>Errors<?= $vs_field_name_prefix.$vs_n; ?>"> </div>
<div class="quickAddSectionBox" id="{$vs_form_name}Container<?= $vs_field_name_prefix.$vs_n; ?>">
<div class="quickAddSectionBox" id="<?= $vs_form_name.'Container'.$vs_field_name_prefix.$vs_n; ?>">
<?php
$va_form_elements = $t_subject->getBundleFormHTMLForScreen($this->getVar('screen'), array(
'request' => $this->request,
'restrictToTypes' => array($t_subject->get('type_id')),
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel') // force query text to be default in label fields
'request' => $this->request,
'restrictToTypes' => array($t_subject->get('type_id')),
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel'), // force query text to be default in label fields
'quickadd' => true
));

print join("\n", $va_form_elements);
Expand Down
11 changes: 6 additions & 5 deletions themes/default/views/editor/occurrences/quickadd_html.php
Expand Up @@ -69,13 +69,14 @@

<div class="quickAddFormTopPadding"><!-- empty --></div>
<div class="quickAddErrorContainer" id="<?= $vs_form_name; ?>Errors<?= $vs_field_name_prefix.$vs_n; ?>"> </div>
<div class="quickAddSectionBox" id="{$vs_form_name}Container<?= $vs_field_name_prefix.$vs_n; ?>">
<div class="quickAddSectionBox" id="<?= $vs_form_name.'Container'.$vs_field_name_prefix.$vs_n; ?>">
<?php
$va_form_elements = $t_subject->getBundleFormHTMLForScreen($this->getVar('screen'), array(
'request' => $this->request,
'restrictToTypes' => array($t_subject->get('type_id')),
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel') // force query text to be default in label fields
'request' => $this->request,
'restrictToTypes' => array($t_subject->get('type_id')),
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel'), // force query text to be default in label fields
'quickadd' => true
));

print join("\n", $va_form_elements);
Expand Down
13 changes: 7 additions & 6 deletions themes/default/views/editor/places/quickadd_html.php
Expand Up @@ -69,7 +69,7 @@

<div class="quickAddFormTopPadding"><!-- empty --></div>
<div class="quickAddErrorContainer" id="<?= $vs_form_name; ?>Errors<?= $vs_field_name_prefix.$vs_n; ?>"> </div>
<div class="quickAddSectionBox" id="{$vs_form_name}Container<?= $vs_field_name_prefix.$vs_n; ?>">
<div class="quickAddSectionBox" id="<?= $vs_form_name.'Container'.$vs_field_name_prefix.$vs_n; ?>">
<?php
// Output hierarchy browser
$va_lookup_urls = caJSONLookupServiceUrl($this->request, 'ca_places');
Expand Down Expand Up @@ -128,11 +128,12 @@
</div>
<?php
$va_form_elements = $t_subject->getBundleFormHTMLForScreen($this->getVar('screen'), array(
'request' => $this->request,
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'restrictToTypes' => array($t_subject->get('type_id')),
'forceLabelForNew' => $this->getVar('forceLabel'), // force query text to be default in label fields
'omit' => array('parent_id')
'request' => $this->request,
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'restrictToTypes' => array($t_subject->get('type_id')),
'forceLabelForNew' => $this->getVar('forceLabel'), // force query text to be default in label fields
'omit' => array('parent_id'),
'quickadd' => true
));

print join("\n", $va_form_elements);
Expand Down
@@ -1,4 +1,4 @@
<?php
<?php
/* ----------------------------------------------------------------------
* app/views/editor/representation_annotations/quickadd_html.php :
* ----------------------------------------------------------------------
Expand Down Expand Up @@ -55,13 +55,14 @@

<div class="quickAddFormTopPadding"><!-- empty --></div>
<div class="caAnnoEditorEditorErrorContainer" id="<?= $vs_form_name; ?>Errors<?= $vs_field_name_prefix.$vs_n; ?>"></div>
<div class="quickAddSectionBox" id="<?= $vs_form_name; ?>Container<?= $vs_field_name_prefix.$vs_n; ?>">
<div class="quickAddSectionBox" id="<?= $vs_form_name.'Container'.$vs_field_name_prefix.$vs_n; ?>">
<?php
$va_form_elements = $t_subject->getBundleFormHTMLForScreen($this->getVar('screen'), array(
'width' => '625px',
'request' => $this->request,
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel') // force query text to be default in label fields
'width' => '625px',
'request' => $this->request,
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel'), // force query text to be default in label fields
'quickadd' => true
));

print join("\n", $va_form_elements);
Expand Down
13 changes: 7 additions & 6 deletions themes/default/views/editor/storage_locations/quickadd_html.php
Expand Up @@ -69,7 +69,7 @@

<div class="quickAddFormTopPadding"><!-- empty --></div>
<div class="quickAddErrorContainer" id="<?= $vs_form_name; ?>Errors<?= $vs_field_name_prefix.$vs_n; ?>"> </div>
<div class="quickAddSectionBox" id="{$vs_form_name}Container<?= $vs_field_name_prefix.$vs_n; ?>">
<div class="quickAddSectionBox" id="<?= $vs_form_name.'Container'.$vs_field_name_prefix.$vs_n; ?>">
<?php
// Output hierarchy browser
$va_lookup_urls = caJSONLookupServiceUrl($this->request, 'ca_storage_locations');
Expand Down Expand Up @@ -128,11 +128,12 @@
</div>
<?php
$va_form_elements = $t_subject->getBundleFormHTMLForScreen($this->getVar('screen'), array(
'request' => $this->request,
'restrictToTypes' => array($t_subject->get('type_id')),
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel'), // force query text to be default in label fields
'omit' => array('parent_id')
'request' => $this->request,
'restrictToTypes' => array($t_subject->get('type_id')),
'formName' => $vs_form_name.$vs_field_name_prefix.$vs_n,
'forceLabelForNew' => $this->getVar('forceLabel'), // force query text to be default in label fields
'omit' => array('parent_id'),
'quickadd' => true
));

print join("\n", $va_form_elements);
Expand Down
4 changes: 2 additions & 2 deletions themes/default/views/system/preferences_quickadd_html.php
Expand Up @@ -7,7 +7,7 @@
* ----------------------------------------------------------------------
*
* Software by Whirl-i-Gig (http://www.whirl-i-gig.com)
* Copyright 2012 Whirl-i-Gig
* Copyright 2012-2022 Whirl-i-Gig
*
* For more information visit http://www.CollectiveAccess.org
*
Expand Down Expand Up @@ -50,7 +50,7 @@
print "<div class='preferenceSectionDivider'><!-- empty --></div>\n";

foreach(array(
'ca_entities', 'ca_places', 'ca_occurrences', 'ca_collections', 'ca_storage_locations'
'ca_entities', 'ca_places', 'ca_occurrences', 'ca_collections', 'ca_storage_locations', 'ca_list_items'
) as $vs_table) {
if (!caTableIsActive($vs_table)) { continue; }
$t_instance = Datamodel::getInstanceByTableName($vs_table, true);
Expand Down

0 comments on commit bd61ef4

Please sign in to comment.