Skip to content

Commit

Permalink
Construct names in Vue.js component (display, rtl, ltr); hide comment…
Browse files Browse the repository at this point in the history
… out non-javascript approach on Person canvas. (CFM-205) (COmanage#75)
  • Loading branch information
arlen committed Feb 22, 2023
1 parent 879838a commit 084f13a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
7 changes: 4 additions & 3 deletions app/templates/People/canvas.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
?>
</div>

<!-- XXX Non-AJAX Approach: Keep the output below as a reference until the component approach above is complete. -->
<hr>
<?php /*
<!-- XXX Non-AJAX Approach: Keep the output below as a reference until the component approach above is complete. -->
<!-- Person Attributes -->
<div id="person-canvas-attributes" class="row row-cols-1 g-4 <?= ($widgetCount > 1) ? 'row-cols-md-2' : ''?>">
<?php
Expand All @@ -109,7 +109,8 @@
}
?>
</div>
<!-- XXX End of Non-AJAX Approach: Keep the output below as a reference until the component approach above is complete. -->
<!-- XXX End of Non-AJAX Approach -->
*/ ?>

<!-- Person Roles -->
<div id="person-canvas-roles" class="card">
Expand Down
18 changes: 14 additions & 4 deletions app/webroot/js/comanage/components/mvea/mvea-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,20 @@ export default {
<!-- Names -->
<li class="field-data-container" v-if="this.core.mveaType == 'names'">
<div class="field-data force-wrap">
<!-- XXX The following must be fixed after discussion of what we will return from the API. The output
can either be properly assembled here (all name components, proper order) or the API can return
a display name. The latter would be best. -->
<a href="#" class="nospin">{{ this.mvea.given }} {{ this.mvea.family }}</a>
<!-- If there is a display name use it. Otherwise, check language and produce right-to-left
order or left-to-right order. This approach is similar to Model/Entity/Name.php::_getFullName().
If we need this construction in other components later, move this to a helper function. -->
<a href="#" class="nospin">
<span v-if="this.mvea.display_name" class="mvea-name-displayname">
{{ this.mvea.display_name }}
</span>
<span v-else-if="['hu', 'ja', 'ko', 'za-Hans', 'za-Hant'].indexOf(this.mvea.language) != -1" class="mvea-name-rtl">
{{ this.mvea.family }} {{ this.mvea.given }}
</span>
<span v-else class="mvea-name-ltr">
{{ this.mvea.honorific }} {{ this.mvea.given }} {{ this.mvea.middle }} {{ this.mvea.family }} {{ this.mvea.suffix }}
</span>
</a>
</div>
<div class="field-data data-label">
<span v-if="this.mvea.primary_name" class="mr-1 badge bg-outline-secondary primary">{{ this.txt.primary }}</span>
Expand Down
26 changes: 26 additions & 0 deletions app/webroot/js/comanage/components/utils/helpers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/**
* COmanage Registry JavaScript Component Helpers
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you 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.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

/**
* Construct human-readable string from language abbreviation code
* BC-47 language tags (https://en.wikipedia.org/wiki/IETF_language_tag)
Expand Down

0 comments on commit 084f13a

Please sign in to comment.