Edirom / MerMEId

Metadata Editor and Repository for MEI Data
https://mermeid.edirom.de/
Apache License 2.0
12 stars 5 forks source link

person-select/person-list.xbl does not show persons without GND #104

Closed gucl-mu closed 2 years ago

gucl-mu commented 2 years ago

If persons in the register do not have a GND, they are not shown in the selection list. Here is the improved code for person_list.xbl. Then the internal ID is used instead of the GND. I have no idea how to do this with the pull request, can someone else please add this?

<xbl:xbl xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:dcm="http://www.kb.dk/dcm" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xxbl="http://orbeon.org/oxf/xml/xbl" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:zs="http://www.loc.gov/zing/srw/">

    <xbl:binding id="dcm-person-list-binding" element="dcm|person-list">
        <metadata xmlns="http://orbeon.org/oxf/xml/form-builder">
            <display-name lang="en">Person selection component</display-name>
        </metadata>

        <xbl:resources>
            <xbl:style/>
        </xbl:resources>
        <xbl:implementation>
            <!-- Local model -->
            <xf:model id="person-model">
                <xf:instance xmlns="http://www.music-encoding.org/ns/mei" id="person-instance">
                    <list/>
                </xf:instance>

                <xf:submission id="load-persons" xxf:show-progress="false" method="get" serialization="none" validate="false" resource="{xxf:instance('parameters')/dcm:library_crud_home}persons.xml" replace="instance" instance="person-instance"/>

                <xf:submission id="load-institutions" xxf:show-progress="false" method="get" serialization="none" validate="false" resource="{xxf:instance('parameters')/dcm:library_crud_home}institutions.xml" replace="instance" instance="person-instance"/>

                <xf:instance id="temp">
                    <temp>
                        <persName/>
                        <id/>
                        <gnd/>
                    </temp>
                </xf:instance> 

                <!-- "onload" xforms actions -->

                <xf:action ev:event="xforms-submit-error" ev:propagate="stop">
                    <xf:var name="code" select="event('response-status-code')"/>
                    <xf:message>Error. Submission return code: <xf:output value="$code"/>
                    </xf:message>
                </xf:action>

            </xf:model>

        </xbl:implementation>

        <xbl:template>
            <xf:group xbl:attr="model context ref bind" xxbl:scope="outer">
                <xf:group appearance="xxf:internal" xxbl:scope="inner">
                    <xf:var name="binding" as="node()?">
                        <xxf:value select="." xxbl:scope="outer"/>
                    </xf:var>

                    <xf:group ref=".[count(instance('person-instance')//m:li/*) &gt; 0]"> 
                        <xf:trigger class="fixed_width">
                            <xf:label>Select from list</xf:label>
                            <xf:action ev:event="DOMActivate">
                                <xf:action if="$binding/local-name() = 'persName'">
                                    <!-- load rism country list -->
                                    <xf:send submission="load-persons"/>
                                </xf:action>

                                <xf:action if="$binding/local-name() = 'corpName'">
                                    <!-- load rism country list -->
                                    <xf:send submission="load-institutions"/>
                                </xf:action>

                                <xf:action if="not($binding/@auth)">
                                  <xf:insert nodeset="@*" context="$binding" origin="xxf:attribute('auth','')"/>
                                </xf:action>
                                <xf:action if="not($binding/@auth.uri)">
                                  <xf:insert nodeset="@*" context="$binding" origin="xxf:attribute('auth.uri','')"/>
                                </xf:action>
                                <xf:action if="not($binding/@codedval)">
                                  <xf:insert nodeset="@*" context="$binding" origin="xxf:attribute('codedval','')"/>
                                </xf:action>
                                <xf:action if="not($binding/@corresp)">
                                  <xf:insert nodeset="@*" context="$binding" origin="xxf:attribute('corresp','')"/>
                                </xf:action>
                                <xf:var name="name" select="normalize-space($binding)"/>
                                <xf:var name="id" select="$binding/@corresp"/>
                                <xf:var name="gnd" select="$binding/@codedval"/>
                                <xf:setvalue ref="instance('temp')/persName" value="$name"/>
                                <xf:setvalue ref="instance('temp')/id" value="$id"/>
                                <xf:setvalue ref="instance('temp')/gnd" value="$gnd"/>
                                <xxf:show dialog="person-dialog"/>
                            </xf:action>
                        </xf:trigger>
                    </xf:group>

                    <xf:action ev:event="xforms-enabled" if="count(@role)!=1">
                        <xf:action if="$binding/local-name() = 'corpName'">
                            <!-- load rism country list -->
                            <xf:send submission="load-institutions"/>
                        </xf:action>
                        <xf:action if="$binding/local-name() = 'persName'">
                            <!-- load rism country list -->
                            <xf:send submission="load-persons"/>
                        </xf:action>
                    </xf:action>

                    <xf:group ref=".[normalize-space($binding)]">
                        <xf:var name="name" select="normalize-space($binding)"/>
                        <xf:group ref=".[count(instance('person-instance')//m:li/*) &gt; 0 and not(instance('person-instance')//m:li/*/*[./text() = $name])]">
                            <h:img src="{xxf:instance('parameters')/dcm:server_name}/editor/images/warning.png" style="vertical-align:middle;" title="MerMEId does not recognize the person '{$name}'."/>
                        </xf:group>
                    </xf:group>

                    <xxf:dialog id="person-dialog" appearance="full" level="modal" close="true" draggable="true" visible="false">
                        <xf:label>Person selection</xf:label>
                        <xf:select1 ref="instance('temp')/id" xxf:refresh-items="false" class="maxlong">
                            <xf:label class="fixed_width">Name</xf:label>
                            <xf:item>
                                <xf:label>- Select name -</xf:label>
                                <xf:value/>
                            </xf:item>
                            <xf:itemset nodeset="instance('person-instance')//m:li/*">
                                <xf:label ref="./*[contains(@type, 'main')]"/>
                                <xf:value ref="./m:identifier[@label='Register-ID']/text()"/>
                            </xf:itemset>
                        </xf:select1>      
                        <h:br/> 
                        <h:br/>
                        <xf:trigger>
                            <xf:label> OK </xf:label>
                            <xf:action ev:event="DOMActivate">
                                <xf:var name="el" select="instance('person-instance')//m:li/*[./m:identifier[./text() = instance('temp')/id]]"/>
                                <xf:setvalue ref="instance('temp')/persName" value="$el/*[@type='main']"/>
                                <xf:setvalue ref="$binding" value="instance('temp')/persName"/>
                                <xf:setvalue ref="$binding/@codedval" value="$el/m:identifier[@auth = 'GND']/text()"/>
                                <xf:setvalue ref="$binding/@corresp" value="$el/m:identifier[@label = 'Register-ID']/text()"/>
                                <xf:setvalue ref="$binding/@auth" value="$el/m:identifier[@auth]/@auth"/>
                                <xf:setvalue ref="$binding/@auth.uri" value="$el/m:identifier[@auth]/@auth.uri"/>
                                <xxf:hide dialog="person-dialog"/>
                            </xf:action>
                        </xf:trigger>
                        <xf:trigger>
                            <xf:label> Cancel </xf:label>
                            <xf:action ev:event="DOMActivate">
                                <xxf:hide dialog="person-dialog"/>
                            </xf:action>
                        </xf:trigger>
                    </xxf:dialog>

                    <dcm:attribute-editor ref="$binding"/>
                </xf:group>
            </xf:group>
        </xbl:template>
    </xbl:binding>
</xbl:xbl>
peterstadler commented 2 years ago

Hi @gucl-mu , I committed your changes to the #105 PR – could you please check that it does what you want or tell me how to check?