google-nomulus/java/google/registry/ui/soy/registrar/ContactSettings.soy
mcilwain b5fb62c984 Change all foreach loops in Soy templates to use the for loop syntax
This also updates to a newer version of Closure Rules and fixes a protobuf dep
compile issue.

Full description of the change:

Soy supports 2 kinds of loops:
* foreach- for iterating over items in a collection, e.g.
  {foreach $item in $list}...{/foreach}
* for - for indexed iteration, e.g. {for $i in range(0, 10)}...{/for}

The reason Soy has two different loops is an accident of history; Soy didn’t use
to have a proper grammar for expressions and so the alternate ‘for...range’
syntax was added to make it possible to write indexed loops.  As the grammar has
improved having the two syntaxes is no longer necessary and so we are
eliminating one of them.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182843207
2018-01-23 16:16:53 -05:00

331 lines
12 KiB
Text

// Copyright 2017 The Nomulus Authors. All Rights Reserved.
//
// Licensed 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.
{namespace registry.soy.registrar.contacts}
/** Registrar contacts listing for view only. */
{template .set}
{@param contactsByType: map<string, ?>}
{let $possibleTypesLookup: [
['admin', 'Primary', 'Primary contact for general issues.'],
['billing', 'Billing', 'Contact for financial communications & invoices.'],
['tech', 'Technical', 'Contact for technical communications about the registry.'],
['legal', 'Legal', 'Contact for all legal communications.'],
['marketing', 'Marketing', 'Contact for registry promotions and campaigns.'],
['abuse', 'Abuse', 'Contact for abuse complaints.'],
['whois', 'WHOIS-Inquiry', 'Contact for inquiries about WHOIS accuracy.'],
['other', 'Other', 'Contact that is none of the above types']] /}
<div class="{css('set')}">
<h1>Contact settings</h1>
<table>
{for $type in $possibleTypesLookup}
{if isNonnull($contactsByType[$type[0]])}
<tr class="{css('kd-settings-pane-section')}">
<td>
<label class="{css('setting-label')}">{$type[1]}
{sp}contact{if length($contactsByType[$type[0]]) > 1}s{/if}</label>
<span class="{css('description')}">{$type[2]}</span>
</td>
<td id="{$type[0]}-contacts"
class="{css('info')} {css('summary')} {css('domain-registrar-contacts')}">
{for $c in $contactsByType[$type[0]]}
{call .contactInfoCompact}
{param namePrefix: 'contacts[' + index($c) + '].' /}
{param name: $c['name'] /}
{param emailAddress: $c['emailAddress'] /}
{param visibleInWhois:
($c['visibleInWhoisAsAdmin']
or $c['visibleInWhoisAsTech']
or $c['visibleInDomainWhoisAsAbuse']) /}
{param phoneNumber: $c['phoneNumber'] /}
{param faxNumber: $c['faxNumber'] /}
{/call}
{if (index($c) + 1) % 3 == 0}<br>{/if}
{/for}
</td>
{/if}
{/for}
</table>
</div>
{/template}
/** Compact readonly contact info view. */
{template .contactInfoCompact}
{@param namePrefix: string}
{@param name: string}
{@param emailAddress: string}
{@param visibleInWhois: bool}
{@param? phoneNumber: string}
{@param? faxNumber: string}
<div class="{css('domain-registrar-contact')}">
<div class="{css('domain-registrar-contact-name')}"
id="{$namePrefix}name">
{$name}
{if $visibleInWhois}
<i class="{css('domain-registrar-contact-visible-in-whois')}"
onmouseover="this.childNodes[0].style.visibility = 'visible'"
onmouseout="this.childNodes[0].style.visibility = 'hidden'">
<div class="{css('tooltip')}">
Visible in WHOIS <span class="{css('pointer')}"></span>
</div>
</i>
{/if}
</div>
{if isNonnull($phoneNumber)}
<div class="{css('domain-registrar-contact-phoneNumber')}"
id="{$namePrefix}phoneNumber">{$phoneNumber}</div>
{/if}
{if isNonnull($faxNumber)}
<div class="{css('domain-registrar-contact-faxNumber')}"
id="{$namePrefix}faxNumber">{$faxNumber} (Fax)</div>
{/if}
<div class="{css('domain-registrar-contact-emailAddress')}"
id="{$namePrefix}emailAddress">{$emailAddress}</div>
<a href="#contact-settings/{$emailAddress}">View/Edit</a>
</div>
{/template}
/** Registrar contact item page. */
{template .contact}
{@param namePrefix: string}
{@param item: map<string, ?>}
{@param actualTypesLookup: map<string, bool>}
{@param readonly: bool}
<form name="item" class="{css('item')} {css('registrar')}">
<h1>Contact Details</h1>
{call .contactInfo data="all"}
{param namePrefix: $namePrefix /}
{param item: $item /}
{param actualTypesLookup: $actualTypesLookup /}
{param readonly: $readonly /}
{/call}
</form>
{/template}
/** Contact info for view and edit. */
{template .contactInfo}
{@param namePrefix: string}
{@param item: map<string, ?>}
{@param actualTypesLookup: map<string, bool>}
{@param? readonly: bool}
{let $possibleTypesLookup: [
['admin', 'Primary', 'Primary contact for general issues.'],
['billing', 'Billing', 'Contact for financial communications & invoices.'],
['tech', 'Technical', 'Contact for technical communications about the registry.'],
['legal', 'Legal', 'Contact for all legal communications.'],
['marketing', 'Marketing', 'Contact for registry promotions and campaigns.'],
['abuse', 'Abuse', 'Contact for abuse complaints.'],
['whois', 'WHOIS-Inquiry', 'Contact for inquiries about WHOIS accuracy.']] /}
<div>
<table>
{call registry.soy.forms.inputFieldRow data="all"}
{param label: 'Name' /}
{param namePrefix: $namePrefix /}
{param name: 'name' /}
{/call}
{call registry.soy.forms.inputFieldRow data="all"}
{param label: 'Email' /}
{param namePrefix: $namePrefix /}
{param name: 'emailAddress' /}
{/call}
{call registry.soy.forms.inputFieldRow data="all"}
{param label: 'Phone' /}
{param namePrefix: $namePrefix /}
{param name: 'phoneNumber' /}
{/call}
{call registry.soy.forms.inputFieldRow data="all"}
{param label: 'Fax' /}
{param namePrefix: $namePrefix /}
{param name: 'faxNumber' /}
{/call}
{if $readonly}
{call .contactTypeSettingsView_}
{param item: $item /}
{param possibleTypesLookup: $possibleTypesLookup /}
{param actualTypesLookup: $actualTypesLookup /}
{/call}
{else}
{call .contactTypeSettingsEdit_}
{param item: $item /}
{param namePrefix: $namePrefix /}
{param possibleTypesLookup: $possibleTypesLookup /}
{param actualTypesLookup: $actualTypesLookup /}
{/call}
{/if}
</table>
{if isNonnull($item['gaeUserId'])}
<input type="hidden" name="{$namePrefix}gaeUserId" value="{$item['gaeUserId']}">
{/if}
</div>
{/template}
/** @private */
{template .contactTypeSettingsView_ visibility="private"}
{@param item: map<string, ?>}
{@param possibleTypesLookup: list<list<string>>}
{@param actualTypesLookup: map<string, bool>}
<tr class="{css('kd-settings-pane-section')}">
<td>
<label class="{css('setting-label')}">Contact type</label>
<td class="{css('setting')}">
<div class="{css('setting-item-list')}">
{for $type in $possibleTypesLookup}
{if $actualTypesLookup[$type[0]]}
<div>{$type[1]} contact</div>
{/if}
{/for}
</div>
</td>
<tr><td colspan="2"><hr></tr>
<tr class="{css('kd-settings-pane-section')}">
<td>
<label class="{css('setting-label')}">Show in WHOIS</label>
</td>
<td class="{css('setting')}">
<p class="{css('setting-item-list')}">
{let $visibleAsAdmin: $item['visibleInWhoisAsAdmin'] == true /}
{let $visibleAsTech: $item['visibleInWhoisAsTech'] == true /}
{let $visibleAsDomainAbuse: $item['visibleInDomainWhoisAsAbuse'] == true /}
{if (not $visibleAsAdmin) and (not $visibleAsTech) and (not $visibleAsDomainAbuse)}
<span class="{css('whois-not-visible')}">Not visible in WHOIS</span>
{else}
{if $visibleAsAdmin}Registrar Admin{/if}
{if $visibleAsAdmin and $visibleAsTech},{sp}{/if}
{if $visibleAsTech}Registrar Technical{/if}
{if $visibleAsTech}
{if $visibleAsDomainAbuse},{sp}{/if}
{elseif $visibleAsAdmin and $visibleAsDomainAbuse},{sp}{/if}
{if $visibleAsDomainAbuse}Domain Abuse{/if}
{/if}
{/template}
/** @private */
{template .contactTypeSettingsEdit_ visibility="private"}
{@param item: map<string, ?>}
{@param namePrefix: string}
{@param possibleTypesLookup: list<list<string>>}
{@param actualTypesLookup: map<string, bool>}
<tr class="{css('kd-settings-pane-section')}">
<td>
<label class="{css('setting-label')}">Contact type</label>
<span class="{css('description')}">
Subscribe this contact to the checked mailing lists.
</span>
</td>
<td class="{css('setting')}">
{call .contactCheckboxes_}
{param namePrefix: $namePrefix /}
{param possibleTypesLookup: $possibleTypesLookup /}
{param actualTypesLookup: $actualTypesLookup /}
{/call}
</tr>
<tr><td colspan="2"><hr></tr>
{call .whoisVisibleRadios_}
{param description: 'Show in Registrar WHOIS record as Admin contact' /}
{param fieldName: $namePrefix + 'visibleInWhoisAsAdmin' /}
{param visible: $item['visibleInWhoisAsAdmin'] == true /}
{/call}
{call .whoisVisibleRadios_}
{param description: 'Show in Registrar WHOIS record as Technical contact' /}
{param fieldName: $namePrefix + 'visibleInWhoisAsTech' /}
{param visible: $item['visibleInWhoisAsTech'] == true /}
{/call}
{call .whoisVisibleRadios_}
{param description:
'Show Phone and Email in Domain WHOIS Record as Registrar Abuse Contact' +
' (Per CL&D Requirements)'
/}
{param note:
'*Can only apply to one contact. Selecting Yes for this contact will' +
' force this setting for all other contacts to be No.'
/}
{param fieldName: $namePrefix + 'visibleInDomainWhoisAsAbuse' /}
{param visible: $item['visibleInDomainWhoisAsAbuse'] == true /}
{/call}
{/template}
/** @private */
{template .whoisVisibleRadios_ visibility="private"}
{@param description: string}
{@param? note: string}
{@param fieldName: string}
{@param visible: bool}
<tr class="{css('kd-settings-pane-section')}">
<td>
<label for="{$fieldName}">{$description}</label>
{if $note}
<span class="{css('description')}">{$note}</span>
{/if}
</td>
<td class="{css('setting')}">
<label for="{$fieldName}">
<input
name="{$fieldName}"
id="{$fieldName}.true"
type="radio"
value="true"
{if $visible} checked{/if}>{sp}Yes
</label>
<label for="{$fieldName}">
<input
name="{$fieldName}"
id="{$fieldName}.false"
type="radio"
value="false"
{if not $visible} checked{/if}>{sp}No
</label>
</td>
{/template}
/** @private */
{template .contactCheckboxes_ visibility="private"}
{@param namePrefix: string}
{@param actualTypesLookup: map<string, bool>}
{@param possibleTypesLookup: list<list<string>>}
{for $type in $possibleTypesLookup}
{let $name: $namePrefix + 'type.' + $type[0] /}
{let $checked: $actualTypesLookup[$type[0]] /}
<div class="{css('checkbox-with-label')}">
<input type="checkbox"
name="{$name}"
id="{$name}"
{if $checked} checked{/if}>
<label for="{$name}">
{$type[1]} contact
<span class="{css('description')}">{$type[2]}</span>
</label>
</div>
{/for}
{/template}
/** IP address form input. */
{template .ip}
{@param name: string}
{@param ip: string}
<div class="{css('ip')}">
<input name="{$name}" value="{$ip}" readonly>
<button type="button" class="{css('kd-button')} {css('btn-remove')} {css('hidden')}">
<i class="{css('icon-remove')} {css('edit')}">x</i>
</button>
</div>
{/template}