Skip to content

Commit

Permalink
Add actor name in subType field, refs #6049
Browse files Browse the repository at this point in the history
Include the actual actor name after the terms in the subType autocomplete field
to give more context. A few js changes to allow bold a part of the dorpdown
values and to add the actor name when the dialog is loaded
  • Loading branch information
jraddaoui committed Dec 20, 2013
1 parent aa0d3c3 commit 676545a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
4 changes: 2 additions & 2 deletions apps/qubit/modules/term/templates/autocompleteSuccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<tr>
<td>
<?php if ($item instanceof QubitTerm): ?>
<?php echo link_to(render_title($item), array($item, 'module' => 'term')) ?>
<?php echo link_to(isset($sf_request->addWords) ? '<b>'.render_title($item).'</b> '.$sf_request->addWords : render_title($item), array($item, 'module' => 'term')) ?>
<?php else: ?>
<?php echo link_to(__('%1% (use: %2%)', array('%1%' => $item[1], '%2%' => render_title($item[0]))), url_for(array($item[0], 'module' => 'term'))) ?>
<?php echo link_to(__(isset($sf_request->addWords) ? '<b>%1% (use: %2%)</b> '.$sf_request->addWords : '%1% (use: %2%)', array('%1%' => $item[1], '%2%' => render_title($item[0]))), url_for(array($item[0], 'module' => 'term'))) ?>
<?php endif; ?>
</td>
</tr>
Expand Down
12 changes: 11 additions & 1 deletion js/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,17 @@
//
// Use XML() constructor as with multiple <select/>, but
// use toString() to get text of parsed HTML
$input.val(args[2][0]);
if (args[2][0].indexOf('<b>') >= 0 && args[2][0].indexOf('</b>') >= 0)
{
// Remove bold tags
$input.val(args[2][0].substring(0, args[2][0].indexOf('<b>'))
+ args[2][0].substring(args[2][0].indexOf('<b>') + 3, args[2][0].indexOf('</b>'))
+ args[2][0].substring(args[2][0].indexOf('</b>') + 4, args[2][0].length));
}
else
{
$input.val(args[2][0]);
}
});

if ($(select).attr('multiple'))
Expand Down
16 changes: 13 additions & 3 deletions js/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,19 @@
scope: $(hiddenInput),
success: function (request, response)
{
this
.next('.form-autocomplete')
.val(response.results[0]);
if (this.attr('name') == 'relatedAuthorityRecord[subType]')
{
// Set value + actor name for subType field
this
.next('.form-autocomplete')
.val(response.results[0] + thisData['relatedAuthorityRecord[actor]']);
}
else
{
this
.next('.form-autocomplete')
.val(response.results[0]);
}
} });
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
</td><td>
<?php if ($item->type->parentId != QubitTerm::ROOT_ID): ?>
<?php if ($resource->id != $item->objectId): ?>
<?php echo $item->type ?>
<?php echo $item->type.' '.render_title($resource) ?>
<?php elseif (0 < count($converseTerms = QubitRelation::getBySubjectOrObjectId($item->type->id, array('typeId' => QubitTerm::CONVERSE_TERM_ID)))): ?>
<?php echo $converseTerms[0]->getOpposedObject($item->type) ?>
<?php echo $converseTerms[0]->getOpposedObject($item->type).' '.render_title($resource) ?>
<?php endif; ?>
<?php endif; ?>
</td><td>
Expand Down Expand Up @@ -121,6 +121,8 @@
response.subType = response.converseSubType;
}
response.actor = ' $resource';
return response;
} });
Expand Down Expand Up @@ -165,7 +167,7 @@
->label(__('Relationship type'))
->renderLabel() ?>
<?php echo $form->subType->render(array('class' => 'form-autocomplete', 'disabled' => 'true')) ?>
<input class="list" type="hidden" value="<?php echo url_for(array('module' => 'term', 'action' => 'autocomplete', 'taxonomy' => url_for(array(QubitTaxonomy::getById(QubitTaxonomy::ACTOR_RELATION_TYPE_ID), 'module' => 'taxonomy')))) ?>"/>
<input class="list" type="hidden" value="<?php echo url_for(array('module' => 'term', 'action' => 'autocomplete', 'taxonomy' => url_for(array(QubitTaxonomy::getById(QubitTaxonomy::ACTOR_RELATION_TYPE_ID), 'module' => 'taxonomy')), 'addWords' => render_title($resource))) ?>"/>
<?php echo $form->subType
->help(__('"Select a descriptive term from the drop-down menu to clarify the type of relationship between these two actors."'))
->renderHelp() ?>
Expand Down

0 comments on commit 676545a

Please sign in to comment.