Hi Richard,
You're on the right track. The changes you made around line 125 of
condition.htm look right.
> My question is, where and how do I generate new branchlists that they show
> #disturbances-effect-section' and #disturbances-cause-section'?
The problem with your current branch lists is that they reference the same
html element #disturbances-section.
Here's how you would fix this.
First in condition.htm, change the second section <dl id=
"disturbances-section">to be <dl id="disturbances-cause-section">
Then in condition.js change this:
this.addBranchList(new BranchList({
el: this.$el.find('#disturbances-section')[0],
data: currentEditedAssessment,
dataKey: 'DISTURBANCE_CAUSE_TYPE.E55'
}));
to this:
this.addBranchList(new BranchList({
el: this.$el.find('#disturbances-cause-section')[0],
data: currentEditedAssessment,
dataKey: 'DISTURBANCE_CAUSE_TYPE.E55'
}));
You should now see both dropdowns being populated.
Hope this helps.
Cheers,
Alexei
Director of Web Development - Farallon Geographics, Inc. - 971.227.3173
On Thu, Jul 23, 2015 at 3:08 AM, Richard Jennings <[email protected]>
wrote:
> Hi Adam and other developers,
>
> Thanks for your recent post Adam and for Hannes for initiating a
> discussion on modifying Arches, as I am now at this stage with our Eamena
> project, in which we are mapping endangered cultural heritage sites across
> North Africa and the Middle East. Arches is the perfect tool for the job so
> thanks also to Dennis and the team for making this available. I've looked
> at your very helpful github files Adam to begin the process of making some
> minor tweaks to the HIP to suit our needs. To that effect I have been
> immersed in code over the last few days getting to get a handle on which
> scripts to change.
>
> I am starting by modifying Part 3 of the conditions form so that we have
> an additional entity called disturbance_effect_type and we replace
> disturbance_type with disturbance_cause_type. I had previously loaded
> authority documents for these new nodes and have placed them on the
> resource graph.
>
> I thought an efficient way to do this would be to modify and duplicate the
> disturbance_type node. I have done this in forms.py, condition.js and
> condition.htm, but realise that there is a problem in that while
> disturbance_cause_type and disturbance_effect_type appear on the form after
> making the modifications, only one works properly in terms of dropdown
> menus, whereas there is no dropdown menu in the other. I have narrowed the
> problem down to the fact that both files have the same hashtag
> '#disturbances-section' .(see below). My question is, where and how do I
> generate new branchlists that they show #disturbances-effect-section'
> and #disturbances-cause-section'?
>
> This is an extract from my modified condition.js:
>
> this.addBranchList(new BranchList({
>
> el: this.$el.find('#disturbances-section')[0],
>
> data: currentEditedAssessment,
>
> dataKey: 'DISTURBANCE_CAUSE_TYPE.E55'
>
> }));
>
>
>
> this.addBranchList(new BranchList({
>
> el: this.$el.find('#disturbances-section')[0],
>
> data: currentEditedAssessment,
>
> dataKey: 'DISTURBANCE_EFFECT_TYPE.E55'
>
> }));
>
> This is an extract from my modified forms.py:
>
> for value in data['CONDITION_ASSESSMENT.E14']:
>
> for node in value['nodes']:
>
> if node['entitytypeid'] == 'CONDITION_ASSESSMENT.E14' and
> node['entityid'] != '':
>
> #remove the node
>
> self.resource.filter(lambda entity: entity.entityid
> != node['entityid'])
>
>
> self.update_nodes('CONDITION_TYPE.E55', data)
>
> self.update_nodes('THREAT_TYPE.E55', data)
>
> self.update_nodes('RECOMMENDATION_TYPE.E55', data)
>
> self.update_nodes('DATE_CONDITION_ASSESSED.E49', data)
>
> self.update_nodes('CONDITION_DESCRIPTION.E62', data)
>
> self.update_nodes('DISTURBANCE_CAUSE_TYPE.E55', data)
>
> self.update_nodes('DISTURBANCE_EFFECT_TYPE.E55', data)
>
> self.update_nodes('CONDITION_IMAGE.E73', data)
>
> self.resource.merge_at(self.baseentity, self.resource.entitytypeid)
>
> self.resource.trim()
>
>
>
> def load(self, lang):
>
>
> self.data = {
>
> 'data': [],
>
> 'domains': {
>
> 'DISTURBANCE_CAUSE_TYPE.E55': Concept().get_e55_domain(
> 'DISTURBANCE_CAUSE_TYPE.E55'),
>
> 'DISTURBANCE_EFFECT_TYPE.E55': Concept().get_e55_domain(
> 'DISTURBANCE_EFFECT_TYPE.E55'),
>
> 'CONDITION_TYPE.E55' : Concept().get_e55_domain(
> 'CONDITION_TYPE.E55'),
>
> 'THREAT_TYPE.E55' : Concept().get_e55_domain(
> 'THREAT_TYPE.E55'),
>
> 'RECOMMENDATION_TYPE.E55' : Concept().get_e55_domain(
> 'RECOMMENDATION_TYPE.E55')
>
> }
>
> }
>
>
> condition_assessment_entities =
> self.resource.find_entities_by_type_id('CONDITION_ASSESSMENT.E14')
>
>
> for entity in condition_assessment_entities:
>
> self.data['data'].append({
>
> 'DISTURBANCE_CAUSE_TYPE.E55': {
>
> 'branch_lists': self.get_nodes(entity,
> 'DISTURBANCE_CAUSE_TYPE.E55')
>
> },
>
> 'DISTURBANCE_EFFECT_TYPE.E55': {
>
> 'branch_lists': self.get_nodes(entity,
> 'DISTURBANCE_EFFECT_TYPE.E55')
>
> },
>
> 'CONDITION_TYPE.E55': {
>
> 'branch_lists': self.get_nodes(entity,
> 'CONDITION_TYPE.E55')
>
> },
>
> 'THREAT_TYPE.E55': {
>
> 'branch_lists': self.get_nodes(entity,
> 'THREAT_TYPE.E55')
>
> },
>
> 'RECOMMENDATION_TYPE.E55': {
>
> 'branch_lists': self.get_nodes(entity,
> 'RECOMMENDATION_TYPE.E55')
>
> },
>
> 'DATE_CONDITION_ASSESSED.E49': {
>
> 'branch_lists':
> datetime_nodes_to_dates(self.get_nodes(entity,
> 'DATE_CONDITION_ASSESSED.E49'))
>
> },
>
> 'CONDITION_DESCRIPTION.E62': {
>
> 'branch_lists': self.get_nodes(entity,
> 'CONDITION_DESCRIPTION.E62')
>
> },
>
> 'CONDITION_IMAGE.E73': {
>
> 'branch_lists': self.get_nodes(entity,
> 'CONDITION_IMAGE.E73')
>
> },
>
> 'CONDITION_ASSESSMENT.E14': {
>
> 'branch_lists': self.get_nodes(entity,
> 'CONDITION_ASSESSMENT.E14')
>
> }
>
> })
>
>
> And these two extracts are of where I made changes to conditions.htm:
>
> 1. from c. line 125:
>
> </dl>
>
>
> <dl>
>
> <dt class="arches-evaluation-header">{% trans
> "Disturbances" %}</dt>
>
> <dd data-bind="foreach:
> $data['DISTURBANCE_CAUSE_TYPE.E55'].branch_lists" class=
> "arches-evaluation-content">
>
> <span data-bind="text: nodes[0].label"
> ></span><br>
>
> </dd>
>
> <dd class="arches-evaluation-content"
> data-bind="ifnot: $data['DISTURBANCE_CAUSE_TYPE.E55'].branch_lists.length
> > 0">
>
> <span data-bind="html: 'no entries'"
> ></span>
>
> </dd>
>
> </dl>
>
>
>
>
>
> <dl>
>
> <dt class="arches-evaluation-header">{% trans
> "Disturbances" %}</dt>
>
> <dd data-bind="foreach:
> $data['DISTURBANCE_EFFECT_TYPE.E55'].branch_lists" class=
> "arches-evaluation-content">
>
> <span data-bind="text: nodes[0].label"
> ></span><br>
>
> </dd>
>
> <dd class="arches-evaluation-content"
> data-bind="ifnot:
> $data['DISTURBANCE_EFFECT_TYPE.E55'].branch_lists.length > 0">
>
> <span data-bind="html: 'no entries'"
> ></span>
>
> </dd>
>
> </dl>
>
> 2. from the Condition assessment wizard container:
>
> <!-- Tab 3: Threats/Disturbances -->
>
> <div class="tab-pane" id=
> "tab3" style="min-height: 630px;">
>
> <br>
>
> <h3 class=
> "margin-bottom-5"><strong>{% trans "Part 3" %}</strong> {% trans
> "Disturbances and Threats" %}</h3>
>
>
> <div class="alert
> alert-info fade in">
>
> <i class="fa-fw fa
> fa-info"></i>
>
> {% trans "Describe the
> threats and disturbances present during your condition assessment." %}
>
> </div>
>
>
> <!-- Form for screens >
> XS -->
>
> <dl id="disturbances-section">
>
> <!-- Title -->
>
> <dt>
>
> <h5 id=
> "arches-names-form" class="section-headline">{% trans "Threats (possible
> impacts)" %}</h5>
>
> </dt>
>
>
>
> <!-- Form -->
>
> <dd class=
> "arches-RDM-labels">
>
>
>
> <div class="row">
>
>
>
> <div class=
> "col-xs-12">
>
>
>
> <input
> style="height: 36px; width:80%; padding-top: 2px;" class="select2
> arches-select2-crud-form" data-bind="select2: {value:
> getEditedNode('DISTURBANCE_EFFECT_TYPE.E55', 'value'), dataKey:
> 'DISTURBANCE_EFFECT_TYPE.E55'}"></input>
>
>
>
> {% include
> 'views/components/add-item-button.htm' %}
>
>
>
> </div>
>
>
>
> <!-- User's
> Selected Threats -->
>
> <div class=
> "row">
>
> <div class
> ="col-xs-12">
>
>
>
> <div
> class="margin-left-5">
>
> <dl
> class="margin-bottom-10">
>
>
>
>
>
> <dd class="margin-left-10 margin-top-5" style="display: none;" data-bind
> ="visible: true">
>
>
> <div data-bind="visible: getBranchLists().length == 0" class=
> "txt-color-blue">{% trans "No threats selected" %}</div>
>
>
>
>
>
> <div data-bind="foreach: getBranchLists()">
>
>
> <div class="arches-crud-record">
>
>
> <a href="javascript:void(0)" class="arches-CRUD-child" title
> ="Delete this name"><i data-bind="click: $parent.deleteItem.bind($parent)"
> class="arches-CRUD-delete fa fa-times-circle"></i></a>
>
>
> <a href="javascript:void(0)" class="arches-CRUD-child
> arches-CRUD-edit" data-bind="click: $parent.editItem.bind($parent)" title="{%
> trans "Edit this type" %}"><span data-bind="text:
> nodes.get('DISTURBANCE_EFFECT_TYPE.E55', 'label')" style=
> "padding-right:2px;"></span></a>
>
>
> </div>
>
>
> </div>
>
>
> </dd>
>
>
>
>
>
> </dl>
>
> </div>
>
>
>
> </div>
>
> </div>
>
>
>
> </div>
>
>
>
> </dd>
>
> <!-- End Form -->
>
> </dl>
>
>
>
> <dl id=
> "disturbances-section">
>
> <!-- Title -->
>
> <dt>
>
> <h5 id=
> "arches-names-form" class="section-headline">{% trans "Disturbances
> (causes)" %}</h5>
>
> </dt>
>
>
>
> <!-- Form -->
>
> <dd class=
> "arches-RDM-labels">
>
>
>
> <div class="row">
>
>
>
> <div class=
> "col-xs-12">
>
>
>
> <input
> style="height: 36px; width:80%; padding-top: 2px;" class="select2
> arches-select2-crud-form" data-bind="select2: {value:
> getEditedNode('DISTURBANCE_CAUSE_TYPE.E55', 'value'), dataKey:
> 'DISTURBANCE_CAUSE_TYPE.E55'}"></input>
>
>
>
> {% include
> 'views/components/add-item-button.htm' %}
>
>
>
> </div>
>
>
>
> <!-- User's
> Selected Disturbances -->
>
> <div class=
> "row">
>
> <div class
> ="col-xs-12">
>
>
>
> <div
> class="margin-left-5">
>
> <dl
> class="margin-bottom-10">
>
>
>
>
>
> <dd class="margin-left-10 margin-top-5" style="display: none;" data-bind
> ="visible: true">
>
>
> <div data-bind="visible: getBranchLists().length == 0" class=
> "txt-color-blue">{% trans "No causes selected" %}</div>
>
>
>
>
>
> <div data-bind="foreach: getBranchLists()">
>
>
> <div class="arches-crud-record">
>
>
> <a href="javascript:void(0)" class="arches-CRUD-child" title
> ="Delete this name"><i data-bind="click: $parent.deleteItem.bind($parent)"
> class="arches-CRUD-delete fa fa-times-circle"></i></a>
>
>
> <a href="javascript:void(0)" class="arches-CRUD-child
> arches-CRUD-edit" data-bind="click: $parent.editItem.bind($parent)" title="{%
> trans "Edit this type" %}"><span data-bind="text:
> nodes.get('DISTURBANCE_CAUSE_TYPE.E55', 'label')" style=
> "padding-right:2px;"></span></a>
>
>
> </div>
>
>
> </div>
>
>
> </dd>
>
>
>
>
>
> </dl>
>
> </div>
>
>
>
> </div>
>
> </div>
>
>
>
> </div>
>
> </dd>
>
>
>
> <!-- End Form -->
>
> </dl>
>
>
> </div>
> Any help much appreciated!
>
> Many thanks,
>
> Richard
>
> --
> -- To post, send email to [email protected]. To unsubscribe,
> send email to [email protected]. For more
> information, visit https://groups.google.com/d/forum/archesproject?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Arches Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
-- To post, send email to [email protected]. To unsubscribe, send
email to [email protected]. For more information,
visit https://groups.google.com/d/forum/archesproject?hl=en
---
You received this message because you are subscribed to the Google Groups
"Arches Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.