diff --git a/instance-app/views/contact/edit-list.html b/instance-app/views/contact/edit-list.html new file mode 100644 index 00000000..23b9e388 --- /dev/null +++ b/instance-app/views/contact/edit-list.html @@ -0,0 +1,7 @@ + diff --git a/instance-app/views/contact/edit.html b/instance-app/views/contact/edit.html index fbf176c9..b66b0a15 100644 --- a/instance-app/views/contact/edit.html +++ b/instance-app/views/contact/edit.html @@ -1,12 +1,28 @@ - - - +
+ - - +

+ + - - +

+ + +

- - +

+ + +

+ +

+ + +

+ +
+ Delete + <%= render( 'field_source/trigger-editing.html', { sourceText: sourceText, sourceID: 'source-contact_detail-' + item.id } )%> +
+
+<%= render( 'field_source/display-editing.html', { sourceText: sourceText, sourceID: 'source-contact_detail-' + item.id, field: 'field_sources[contact_details][' + i + ']' } )%> diff --git a/instance-app/views/contact/list.html b/instance-app/views/contact/list.html deleted file mode 100644 index 074fda6a..00000000 --- a/instance-app/views/contact/list.html +++ /dev/null @@ -1,8 +0,0 @@ - diff --git a/instance-app/views/contact/view-list.html b/instance-app/views/contact/view-list.html new file mode 100644 index 00000000..5a046b89 --- /dev/null +++ b/instance-app/views/contact/view-list.html @@ -0,0 +1,7 @@ + diff --git a/instance-app/views/contact/view.html b/instance-app/views/contact/view.html index e6b2393a..3460bdf6 100644 --- a/instance-app/views/contact/view.html +++ b/instance-app/views/contact/view.html @@ -1,4 +1,4 @@ -
+
<% if (item.label) { %> <%- item.label %> (<%- item.type %>): @@ -10,22 +10,9 @@ <% if (item.note) { %> (<%- item.note %>) <% } %> -
-
- Delete - Edit - - <% if (item.label) { %> - <%- item.label %> (<%- item.type %>): - <% } else { %> - <%- item.type %>: - <% } %> - - <%- item.value %> - <% if (item.note) { %> - (<%- item.note %>) - <% } %> -
- - + +
+<%= render( 'field_source/display.html', { sourceText: sourceText, sourceID: 'source-contact-' + item.id } )%> diff --git a/instance-app/views/field_source/display-editing.html b/instance-app/views/field_source/display-editing.html new file mode 100644 index 00000000..e67dcb09 --- /dev/null +++ b/instance-app/views/field_source/display-editing.html @@ -0,0 +1,5 @@ +<% if (popit.setting('require-sources')) { %> +
+ +
+<% } %> diff --git a/instance-app/views/field_source/display.html b/instance-app/views/field_source/display.html new file mode 100644 index 00000000..7e49ce8e --- /dev/null +++ b/instance-app/views/field_source/display.html @@ -0,0 +1,7 @@ +<% if (popit.setting('require-sources')) { %> + <% if (sourceText) { %> +
+ <%- sourceText %> +
+ <% } %> +<% } %> diff --git a/instance-app/views/field_source/edit.html b/instance-app/views/field_source/edit.html new file mode 100644 index 00000000..a2d93cb5 --- /dev/null +++ b/instance-app/views/field_source/edit.html @@ -0,0 +1,12 @@ +<% if (popit.setting('require-sources')) { %> +
+ <% if (value) { %> + Change source + <% } else { %> + Add source + <% } %> +
+ +
+
+<% } %> diff --git a/instance-app/views/field_source/trigger-editing.html b/instance-app/views/field_source/trigger-editing.html new file mode 100644 index 00000000..1af883e2 --- /dev/null +++ b/instance-app/views/field_source/trigger-editing.html @@ -0,0 +1,7 @@ +<% if (popit.setting('require-sources')) { %> + <% if (sourceText) { %> + Change source + <% } else { %> + Add source + <% } %> +<% } %> diff --git a/instance-app/views/field_source/trigger.html b/instance-app/views/field_source/trigger.html new file mode 100644 index 00000000..e35af905 --- /dev/null +++ b/instance-app/views/field_source/trigger.html @@ -0,0 +1,7 @@ +<% if (popit.setting('require-sources')) { %> + <% if (sourceText) { %> + Show source + <% } else { %> + No source + <% } %> +<% } %> diff --git a/instance-app/views/field_source/view.html b/instance-app/views/field_source/view.html new file mode 100644 index 00000000..4b6d4fa6 --- /dev/null +++ b/instance-app/views/field_source/view.html @@ -0,0 +1,12 @@ +<% if (popit.setting('require-sources')) { %> +
+ <% if (value) { %> + Show source + <% } else { %> + No source + <% } %> +
+ <%- value %> +
+
+<% } %> diff --git a/instance-app/views/identifier/edit-list.html b/instance-app/views/identifier/edit-list.html new file mode 100644 index 00000000..46621705 --- /dev/null +++ b/instance-app/views/identifier/edit-list.html @@ -0,0 +1,7 @@ + diff --git a/instance-app/views/identifier/edit.html b/instance-app/views/identifier/edit.html index f5209b90..c10aea2a 100644 --- a/instance-app/views/identifier/edit.html +++ b/instance-app/views/identifier/edit.html @@ -1,6 +1,19 @@ - - - +
+ - - +

+ + +

+ +

+ + +

+ + +
+<%= render( 'field_source/display-editing.html', { sourceText: sourceText, sourceID: 'source-identifier-' + item.id, field: 'field_sources[identifiers][' + i + ']' } )%> diff --git a/instance-app/views/identifier/list.html b/instance-app/views/identifier/list.html deleted file mode 100644 index db7a4c4e..00000000 --- a/instance-app/views/identifier/list.html +++ /dev/null @@ -1,8 +0,0 @@ - diff --git a/instance-app/views/identifier/view-list.html b/instance-app/views/identifier/view-list.html new file mode 100644 index 00000000..3d3e89fa --- /dev/null +++ b/instance-app/views/identifier/view-list.html @@ -0,0 +1,7 @@ + diff --git a/instance-app/views/identifier/view.html b/instance-app/views/identifier/view.html index 3721454a..778055b4 100644 --- a/instance-app/views/identifier/view.html +++ b/instance-app/views/identifier/view.html @@ -1,14 +1,11 @@ -
- <% if (item.scheme) { %> - <%- item.scheme %>: - <% } %> - <%- item.identifier %> -
-
- Delete - Edit + +<%= render( 'field_source/display.html', { sourceText: sourceText, sourceID: 'source-identifier-' + item.id } )%> diff --git a/instance-app/views/link/edit-list.html b/instance-app/views/link/edit-list.html new file mode 100644 index 00000000..e83fa542 --- /dev/null +++ b/instance-app/views/link/edit-list.html @@ -0,0 +1,7 @@ + diff --git a/instance-app/views/link/edit.html b/instance-app/views/link/edit.html index a96cd32d..3169bb22 100644 --- a/instance-app/views/link/edit.html +++ b/instance-app/views/link/edit.html @@ -1,6 +1,19 @@ - - - + +<%= render( 'field_source/display-editing.html', { sourceText: sourceText, sourceID: 'source-link-' + item.id, field: 'field_sources[links][' + i + ']' } )%> diff --git a/instance-app/views/link/list.html b/instance-app/views/link/list.html deleted file mode 100644 index 16043283..00000000 --- a/instance-app/views/link/list.html +++ /dev/null @@ -1,8 +0,0 @@ - diff --git a/instance-app/views/link/view-list.html b/instance-app/views/link/view-list.html new file mode 100644 index 00000000..08c6ae84 --- /dev/null +++ b/instance-app/views/link/view-list.html @@ -0,0 +1,7 @@ + diff --git a/instance-app/views/link/view.html b/instance-app/views/link/view.html index 73e901c9..ae587d77 100644 --- a/instance-app/views/link/view.html +++ b/instance-app/views/link/view.html @@ -1,14 +1,10 @@ -
- - <%- item.note %>: - - <%- item.url %> -
-
- Delete - Edit + +<%= render( 'field_source/display.html', { sourceText: sourceText, sourceID: 'source-link-' + item.id } )%> diff --git a/instance-app/views/membership/list-item.html b/instance-app/views/membership/list-item.html index 04e8ebbc..2e38b7b2 100644 --- a/instance-app/views/membership/list-item.html +++ b/instance-app/views/membership/list-item.html @@ -1,4 +1,7 @@ -
+ +<%= render( 'field_source/display.html', { sourceText: sourceText, sourceID: 'source-membership-' + membership.id } )%> diff --git a/instance-app/views/membership/new.html b/instance-app/views/membership/new.html index fb952b75..1578bef2 100644 --- a/instance-app/views/membership/new.html +++ b/instance-app/views/membership/new.html @@ -1,4 +1,4 @@ -
+ + +<%= render( 'field_source/display-editing.html', { sourceText: sourceText, sourceID: 'source-membership-' + membership.id, field: 'field_sources[membership][' + i + ']' } )%> diff --git a/instance-app/views/organization/form.html b/instance-app/views/organization/form.html index 12739b9a..88b17ae1 100644 --- a/instance-app/views/organization/form.html +++ b/instance-app/views/organization/form.html @@ -7,37 +7,28 @@
-

- <%- organization.name %> - -

- - + + <%= render( 'field_source/display-editing.html', { sourceText: organization.get('field_sources.name'), sourceID: 'source-name-' + organization.id, field: 'field_sources[name]' } )%>
-

- <% if (organization.classification) { %> - <%- organization.classification %> - - <% } else { %> - What type of organization is <%- organization.name %>? - <% } %> -

-
- + -
- -
@@ -55,49 +46,45 @@

- <% if (!organization.other_names.length && !organization.parent_id && !organization.founding_date && !organization.dissolution_date) { %> -

- Add more info - You can use PopIt to store previous names and other important details about this organization. -

- <% } %> - -
-
    - <% _.each(organization.other_names, function(name, i) { %> -
  • - <%= render('other_name/edit.html', {name: name, i: i}) %> - Delete -
  • - <% }) %> -
+ <%= render( 'other_name/edit-list.html', { other_names: organization.other_names, object: organization } ) %> Add a<% if(organization.other_names.length){ %>nother<% } %> name
-

- <% if (organization.parent_id) { %> - <%- organization.parent_id.name %> - <% } %> -

- + + <%= render( 'field_source/display-editing.html', { sourceText: organization.get('field_sources.parent_id'), sourceID: 'source-parent_id-' + organization.id, field: 'field_sources[parent_id]' } )%>
-

<%- organization.founding_date || '' %>

- - + + <%= render( 'field_source/display-editing.html', { sourceText: organization.get('field_sources.founding_date'), sourceID: 'source-founding_date-' + organization.id, field: 'field_sources[founding_date]' } )%>
-

<%- organization.dissolution_date || '' %>

- - + + <%= render( 'field_source/display-editing.html', { sourceText: organization.get('field_sources.dissolution_date'), sourceID: 'source-dissolution_date-' + organization.id, field: 'field_sources[dissolution_date]' } )%>
@@ -107,7 +94,7 @@

<% _.each( memberships, function (membership, i) { %> <% if (validMembership(membership, organization.id)) { %>
  • - <%= render('membership/new.html', { membership: membership, organization: organization, member: relatedObject(membership, organization, lang, defaultLang), type: 'organization', i: i }) %> + <%= render('membership/new.html', { membership: membership, organization: organization, member: relatedObject(membership, organization, lang, defaultLang), type: 'organization', sourceText: organization.get('field_sources.memberships.' + i), i: i }) %>
  • <% } %> <% }); %> @@ -116,18 +103,11 @@

    -
    - <% if (!posts.length) { %> -

    - Add posts - Organizations in PopIt can have pre-defined posts that members can then fill. -

    - <% } %>
      - <% _.each( posts, function ( post ) { %> -
    • <%= render( 'post/post.html', { item: post }) %>
    • + <% _.each( posts, function ( post, i ) { %> +
    • <%= render( 'post/post.html', { item: post, sourceText: organization.get('field_sources.posts.' + i), i: i }) %>
    • <% }); %>
    • Add a<% if(posts.length){ %>nother<% } %> post @@ -137,85 +117,29 @@

    - <% if (!organization.links.length) { %> -

    - Add links to websites - If this organization has a website, or any online profile pages, you can add them here. -

    - <% } %> -
    - + <%= render( 'link/edit-list.html', { links: organization.links, object: organization } ) %> Add a<% if(organization.links.length){ %>nother<% } %> link
    - <% if (!organization.contact_details.length) { %> -

    - Add contact details - PopIt is most useful when people have contact details, like their phone, email, and Twitter. -

    - <% } %> -
    -
      - <% _.each(organization.contact_details, function(contact, i) { %> -
    • - <%= render('contact/edit.html', {contact: contact, i: i}) %> - Delete -
    • - <% }) %> -
    + <%= render( 'contact/edit-list.html', { contact_details: organization.contact_details, object: organization } ) %> Add <% if(organization.contact_details.length){ %>more <% } %>contact details
    - <% if (!organization.sources.length) { %> -

    - Add sources - Add any URLs to documents from which the organization is derived here. -

    - <% } %> -
    -
      - <% _.each(organization.sources, function(source, i) { %> -
    • - <%= render('source/edit.html', {source: source, i: i}) %> - Delete -
    • - <% }) %> -
    + <%= render( 'source/edit-list.html', { sources: organization.sources, object: organization } ) %> Add a<% if(organization.sources.length){ %>nother<% } %> source
    - <% if (!organization.identifiers.length) { %> -

    - Add identifiers - If this organization has special registration or ID numbers, you can add them here. -

    - <% } %> -
    -
      - <% _.each(organization.identifiers, function(identifier, i) { %> -
    • - <%= render('identifier/edit.html', {identifier: identifier, i: i}) %> - Delete -
    • - <% }) %> -
    + <%= render( 'identifier/edit-list.html', { identifiers: organization.identifiers, object: organization } ) %> Add an<% if(organization.identifiers.length){ %>other<% } %> identifier
    diff --git a/instance-app/views/organization/view.html b/instance-app/views/organization/view.html index c60d2ab5..f5a0ce06 100644 --- a/instance-app/views/organization/view.html +++ b/instance-app/views/organization/view.html @@ -61,37 +61,41 @@
    -

    - <%- organization.name %> - -

    - - + + <%= render( 'field_source/display.html', { sourceText: organization.get('field_sources.name'), sourceID: 'source-name-' + organization.id, field: 'field_sources[name]' } )%>
    -

    - <% if (organization.classification) { %> - <%- organization.classification %> - - <% } else { %> - What type of organization is <%- organization.name %>? - <% } %> -

    -
    - + -
    - -
    @@ -118,31 +122,44 @@

    - <%= render( 'other_name/list.html', { other_names: organization.other_names } ) %> + <%= render( 'other_name/view-list.html', { other_names: organization.other_names, object: organization } ) %>
    -

    - <% if (organization.parent_id) { %> - <%- organization.parent_id.name %> - <% } %> -

    - + + <%= render( 'field_source/display.html', { sourceText: organization.get('field_sources.parent_id'), sourceID: 'source-parent_id-' + organization.id } )%>
    -

    <%- organization.founding_date || '' %>

    - - + + <%= render( 'field_source/display.html', { sourceText: organization.get('field_sources.founding_date'), sourceID: 'source-founding_date-' + organization.id } )%>
    -

    <%- organization.dissolution_date || '' %>

    - - + + <%= render( 'field_source/display.html', { sourceText: organization.get('field_sources.dissolution_date'), sourceID: 'source-dissolution_date-' + organization.id } )%>

    @@ -155,14 +172,13 @@

    <% } %>
      - <% _.each( memberships, function ( membership ) { %> + <% _.each( memberships, function ( membership, i ) { %> <% if (validMembership(membership, organization.id)) { %> - <%= render( 'membership/list-item.html', { membership: membership, member: relatedObject(membership, organization, lang, defaultLang), organization: organization, type: 'organization' } ) %> +
    • + <%= render( 'membership/list-item.html', { membership: membership, member: relatedObject(membership, organization, lang, defaultLang), organization: organization, type: 'organization', sourceText: organization.get('field_sources.memberships.' + i) } ) %> +
    • <% } %> <% }); %> -
    • - Add a<% if(posts.length){ %>nother<% } %> member -

    @@ -176,12 +192,9 @@

    <% } %>
      - <% _.each( posts, function ( post ) { %> -
    • <%= render( 'post/post.html', { item: post }) %>
    • + <% _.each( posts, function ( post, i ) { %> +
    • <%= render( 'post/post.html', { item: post, i: i }) %>
    • <% }); %> -
    • - Add a<% if(posts.length){ %>nother<% } %> post -

    @@ -195,7 +208,7 @@

    <% } %>
    - <%= render( 'link/list.html', { links: organization.links } ) %> + <%= render( 'link/view-list.html', { links: organization.links, object: organization } ) %>
    @@ -210,7 +223,7 @@

    <% } %>
    - <%= render( 'contact/list.html', { contact_details: organization.contact_details } ) %> + <%= render( 'contact/view-list.html', { contact_details: organization.contact_details, object: organization } ) %>
    @@ -225,7 +238,7 @@

    <% } %>
    - <%= render( 'source/list.html', { sources: organization.sources } ) %> + <%= render( 'source/view-list.html', { sources: organization.sources, object: organization } ) %>
    @@ -240,7 +253,7 @@

    <% } %>
    - <%= render( 'identifier/list.html', { identifiers: organization.identifiers } ) %> + <%= render( 'identifier/view-list.html', { identifiers: organization.identifiers, object: organization } ) %>
    diff --git a/instance-app/views/other_name/edit-list.html b/instance-app/views/other_name/edit-list.html new file mode 100644 index 00000000..11746449 --- /dev/null +++ b/instance-app/views/other_name/edit-list.html @@ -0,0 +1,7 @@ + diff --git a/instance-app/views/other_name/edit.html b/instance-app/views/other_name/edit.html index eb7e2391..1742e5eb 100644 --- a/instance-app/views/other_name/edit.html +++ b/instance-app/views/other_name/edit.html @@ -1,12 +1,20 @@ - - - + +<%= render( 'field_source/display-editing.html', { sourceText: sourceText, sourceID: 'source-other_name-' + item.id, field: 'field_sources[other_name][' + i + ']' } )%> diff --git a/instance-app/views/other_name/list.html b/instance-app/views/other_name/list.html deleted file mode 100644 index 1fb5318a..00000000 --- a/instance-app/views/other_name/list.html +++ /dev/null @@ -1,8 +0,0 @@ - diff --git a/instance-app/views/other_name/view-list.html b/instance-app/views/other_name/view-list.html new file mode 100644 index 00000000..6b45528e --- /dev/null +++ b/instance-app/views/other_name/view-list.html @@ -0,0 +1,7 @@ + diff --git a/instance-app/views/other_name/view.html b/instance-app/views/other_name/view.html index ac797988..f4328a72 100644 --- a/instance-app/views/other_name/view.html +++ b/instance-app/views/other_name/view.html @@ -1,15 +1,4 @@ -
    - <% if (item.note) { %> - <%- item.note %>: - <% } %> - <%- item.name %> - <% if (item.start_date || item.end_date) { %> - (<%- item.start_date || '?' %> – <%- item.end_date || '?' %>) - <% } %> -
    -
    - Delete - Edit + +<%= render( 'field_source/display.html', { sourceText: sourceText, sourceID: 'source-other_name-' + item.id } )%> diff --git a/instance-app/views/person/form.html b/instance-app/views/person/form.html index 5df771fb..93beb539 100644 --- a/instance-app/views/person/form.html +++ b/instance-app/views/person/form.html @@ -8,8 +8,15 @@
    - - + + <%= render( 'field_source/display-editing.html', { sourceText: person.get('field_sources.name'), sourceID: 'source-name-' + person.id, field: 'field_sources[name]' } )%>
    @@ -26,102 +33,70 @@
    - <% if (!person.other_names.length && !person.summary && !person.birth_date && !person.death_date) { %> -

    - Add details - You can use PopIt to store extra information about this person, like who they are and when they were born. -

    - <% } %> -
    -
      - <% _.each(person.other_names, function(name, i) { %> -
    • - <%= render('other_name/edit.html', {name: name, i: i}) %> - Delete -
    • - <% }) %> -
    + <%= render( 'other_name/edit-list.html', { other_names: person.other_names, object: person } ) %> Add a<% if(person.other_names.length){ %>nother<% } %> name
    - + + <%= render( 'field_source/display-editing.html', { sourceText: person.get('field_sources.summary'), sourceID: 'source-summary-' + person.id, field: 'field_sources[summary]' } )%>
    - - + + <%= render( 'field_source/display-editing.html', { sourceText: person.get('field_sources.birth_date'), sourceID: 'source-birth_date-' + person.id, field: 'field_sources[birth_date]' } )%>
    - - + + <%= render( 'field_source/display-editing.html', { sourceText: person.get('field_sources.death_date'), sourceID: 'source-death_date-' + person.id, field: 'field_sources[death_date]' } )%>
    - <% if (!person.links.length) { %> -

    - Add links to websites - If this person has a website, or any online profile pages, you can add them here. -

    - <% } %> -
    - + <%= render( 'link/edit-list.html', { links: person.links, object: person } ) %> Add a<% if(person.links.length){ %>nother<% } %> link
    - <% if (!person.contact_details.length) { %> -

    - Add contact details - PopIt is most useful when people have contact details, like their phone, email, and Twitter. -

    - <% } %> -
    - -
      - <% _.each(person.contact_details, function(contact, i) { %> -
    • - <%= render('contact/edit.html', {contact: contact, i: i}) %> - Delete -
    • - <% }) %> -
    + <%= render( 'contact/edit-list.html', { contact_details: person.contact_details, object: person } ) %> Add <% if ( person.contact_details.length > 0 ) { %>more <% } %>contact details
    - <% if (!memberships.length) { %> -

    - Add a membership - Is this person a member of an organization or party? -

    - <% } %> -
      <% _.each( memberships, function (membership, i) { %> <% if (validMembership(membership, person.id)) { %>
    • - <%= render('membership/new.html', { membership: membership, member: person, organization: relatedObject(membership, person, lang, defaultLang), type: 'person', i: i }) %> + <%= render('membership/new.html', { membership: membership, member: person, organization: relatedObject(membership, person, lang, defaultLang), type: 'person', sourceText: person.get('field_sources.memberships.' + i), i: i }) %>
    • <% } %> <% }); %> @@ -131,43 +106,15 @@
    - <% if (!person.sources.length) { %> -

    - Add sources - Add any URLs to documents from which the person is derived here. -

    - <% } %> -
    -
      - <% _.each(person.sources, function(source, i) { %> -
    • - <%= render('source/edit.html', {source: source, i: i}) %> - Delete -
    • - <% }) %> -
    + <%= render( 'source/edit-list.html', { sources: person.sources, object: person } ) %> Add a<% if(person.sources.length){ %>nother<% } %> source
    - <% if (!person.identifiers.length) { %> -

    - Add identifiers - If this person has special registration or ID numbers, you can add them here. -

    - <% } %> -
    -
      - <% _.each(person.identifiers, function(identifier, i) { %> -
    • - <%= render('identifier/edit.html', {identifier: identifier, i: i}) %> - Delete -
    • - <% }) %> -
    + <%= render( 'identifier/edit-list.html', { identifiers: person.identifiers, object: person } ) %> Add an<% if(person.identifiers.length){ %>other<% } %> identifier
    diff --git a/instance-app/views/person/view.html b/instance-app/views/person/view.html index 60f04eb8..1de59979 100644 --- a/instance-app/views/person/view.html +++ b/instance-app/views/person/view.html @@ -70,20 +70,23 @@
    -

    - <%- person.name %> - -

    -
    - -
    @@ -101,29 +104,26 @@

    - <% if (!memberships.length) { %> -

    - Add a membership - Is this person a member of an organization or party? -

    - <% } else { %> - Add another membership - <% } %> -
      <% _.each( memberships, function (membership, i) { %> <% if (validMembership(membership, person.id)) { %>
    • - <%= render( 'membership/list-item.html', { membership: membership, member: person, organization: relatedObject(membership, person, lang, defaultLang), type: 'person' } ) %> + <%= render( 'membership/list-item.html', { membership: membership, member: person, organization: relatedObject(membership, person, lang, defaultLang), type: 'person', sourceText: person.get('field_sources.memberships.' + i) } ) %>
    • <% } %> <% }); %> -
    • - Add a<% if(memberships.length){ %>nother<% } %> membership -
    + + <% if (!memberships.length) { %> +

    + Add a membership + Is this person a member of an organization or party? +

    + <% } else { %> + Add another membership + <% } %>
    @@ -136,91 +136,104 @@

    - <%= render( 'other_name/list.html', { other_names: person.other_names } ) %> + <%= render( 'other_name/view-list.html', { other_names: person.other_names, object: person } ) %>
    -

    <%- person.summary %>

    - + + <%= render( 'field_source/display.html', { sourceText: person.get('field_sources.summary'), sourceID: 'source-summary-' + person.id } )%>
    -

    <%- person.birth_date || '' %>

    - - + + <%= render( 'field_source/display.html', { sourceText: person.get('field_sources.birth_date'), sourceID: 'source-birth_date-' + person.id } )%>
    -

    <%- person.death_date || '' %>

    - - + + <%= render( 'field_source/display.html', { sourceText: person.get('field_sources.death_date'), sourceID: 'source-death_date-' + person.id } )%>

    +
    + <%= render( 'link/view-list.html', { links: person.links, object: person } ) %> +
    + <% if (!person.links.length) { %>

    Add links to websites If this person has a website, or any online profile pages, you can add them here.

    <% } else { %> - Add another link + Add another link <% } %> - -
    - <%= render( 'link/list.html', { links: person.links } ) %> -
    +
    + <%= render( 'contact/view-list.html', { contact_details: person.contact_details, object: person } ) %> +
    + <% if (!person.contact_details.length) { %>

    Add contact details PopIt is most useful when people have contact details, like their phone, email, and Twitter.

    <% } else { %> - Add more contact details + Add more contact details <% } %> - -
    - <%= render( 'contact/list.html', { contact_details: person.contact_details } ) %> -
    +
    + <%= render( 'source/view-list.html', { sources: person.sources, object: person } ) %> +
    + <% if (!person.sources.length) { %>

    Add sources Add any URLs to documents from which the person is derived here.

    <% } else { %> - Add another source + Add another source <% } %> - -
    - <%= render( 'source/list.html', { sources: person.sources } ) %> -
    +
    + <%= render( 'identifier/view-list.html', { identifiers: person.identifiers, object: person } ) %> +
    + <% if (!person.identifiers.length) { %>

    Add identifiers If this person has special registration or ID numbers, you can add them here.

    <% } else { %> - Add another identifier + Add another identifier <% } %> - -
    - <%= render( 'identifier/list.html', { identifiers: person.identifiers } ) %> -
    <%= render('disclaimer.html' )%> diff --git a/instance-app/views/post/post.html b/instance-app/views/post/post.html index aaeaf9c4..ce1781ec 100644 --- a/instance-app/views/post/post.html +++ b/instance-app/views/post/post.html @@ -1,10 +1,8 @@ -
    + -
    - Delete - Edit - <%- item.label %> + diff --git a/instance-app/views/post/view.html b/instance-app/views/post/view.html index 673c021a..b7c0ac82 100644 --- a/instance-app/views/post/view.html +++ b/instance-app/views/post/view.html @@ -25,31 +25,55 @@
    -

    - <%- post.label %> -

    + + <%= render( 'field_source/display-editing.html', { sourceText: post.get('field_sources.label'), sourceID: 'source-label-' + post.id, field: 'field_sources[label]' } )%>
    <% if (post.role) { %>
    -

    <%- post.role %>

    + + <%= render( 'field_source/display-editing.html', { sourceText: post.get('field_sources.role'), sourceID: 'source-role-' + post.id, field: 'field_sources[role]' } )%>
    <% } %> <% if (post.area) { %>
    -

    <%- post.area.name %>

    + + <%= render( 'field_source/display-editing.html', { sourceText: post.get('field_sources.area.name'), sourceID: 'source-area-' + post.id, field: 'field_sources[area][name]' } )%>
    <% } %> <% if (post.organization_id) { %>
    -

    - <%- post.organization_id.name %> -

    + + <%= render( 'field_source/display.html', { sourceText: post.get('field_sources.organization_id.name'), sourceID: 'source-organization-' + post.id, field: 'field_sources[organization_id][name]' } )%>
    <% } %> @@ -65,7 +89,7 @@

      <% _.each( memberships, function (membership, i) { %>
    • - <%= render( 'membership/list-item.html', { membership: membership, member: membership.person_id, organization: relatedObject(membership, post, lang, defaultLang), type: 'post' } ) %> + <%= render( 'membership/list-item.html', { membership: membership, member: membership.person_id, organization: relatedObject(membership, post, lang, defaultLang), type: 'post', sourceText: post.get('field_sources.memberships.' + i) } ) %>
    • <% }); %>
    diff --git a/instance-app/views/source/edit-list.html b/instance-app/views/source/edit-list.html new file mode 100644 index 00000000..bab1035f --- /dev/null +++ b/instance-app/views/source/edit-list.html @@ -0,0 +1,7 @@ +
      + <% _.each( sources, function (item, i) { %> +
    • + <%= render( 'source/edit.html', { item: item, sourceText: object.get('field_sources.sources.' + i), i: i }) %> +
    • + <% }); %> +
    diff --git a/instance-app/views/source/edit.html b/instance-app/views/source/edit.html index 9f2b51e3..10e9f79f 100644 --- a/instance-app/views/source/edit.html +++ b/instance-app/views/source/edit.html @@ -1,6 +1,18 @@ - - - + +<%= render( 'field_source/display-editing.html', { sourceText: sourceText, sourceID: 'source-source-' + item.id, field: 'field_sources[sources][' + i + ']' } )%> diff --git a/instance-app/views/source/list.html b/instance-app/views/source/list.html deleted file mode 100644 index a2072508..00000000 --- a/instance-app/views/source/list.html +++ /dev/null @@ -1,8 +0,0 @@ - diff --git a/instance-app/views/source/view-list.html b/instance-app/views/source/view-list.html new file mode 100644 index 00000000..2036c5e5 --- /dev/null +++ b/instance-app/views/source/view-list.html @@ -0,0 +1,7 @@ +
      + <% _.each( sources, function (item, i) { %> +
    • + <%= render( 'source/view.html', { item: item, sourceText: object.get('field_sources.sources.' + i) }) %> +
    • + <% }); %> +
    diff --git a/instance-app/views/source/view.html b/instance-app/views/source/view.html index 4a853036..62efdc4e 100644 --- a/instance-app/views/source/view.html +++ b/instance-app/views/source/view.html @@ -1,14 +1,11 @@ -
    - - <%- item.note %>: - - <%- item.url %> -
    -
    - Delete - Edit + +<%= render( 'field_source/display.html', { sourceText: sourceText, sourceID: 'source-source-' + item.id } )%> diff --git a/lib/apps/about.js b/lib/apps/about.js index 11b80c6d..69b46207 100644 --- a/lib/apps/about.js +++ b/lib/apps/about.js @@ -24,6 +24,7 @@ module.exports = function () { "contact_phone": { type: "textbox", label: "Contact Phone" }, "disclaimer": { type: "textarea", label: "Override disclaimer" }, "no-spider": { type: "checkbox", label: "Do Not Spider" }, + "require-sources": { type: "checkbox", label: "Require sources" }, "license": { type: "textarea", label: "License text" }, }; diff --git a/lib/apps/generic_document.js b/lib/apps/generic_document.js index 68964ff8..233de9ea 100644 --- a/lib/apps/generic_document.js +++ b/lib/apps/generic_document.js @@ -123,6 +123,31 @@ module.exports = function (opts) { next(); }); + // Remove blank values from field_sources object + app.put('/:id(*)', function(req, res, next) { + function removeBlanks(obj) { + var ret = {}; + _.each(obj, function(val, key) { + if (_.isArray(val)) { + var filtered = _.compact(val); + if (filtered.length > 0) { + ret[key] = filtered; + } + } else if (_.isObject(val)) { + ret[key] = removeBlanks(val); + } else { + if (val) { + ret[key] = val; + } + } + }); + return ret; + } + + req.body.field_sources = removeBlanks(req.body.field_sources); + next(); + }); + function save_as_multilingual(body, obj, lang, defaultLang) { if (!body) { return; @@ -133,7 +158,7 @@ module.exports = function (opts) { if ( !item && !body[field] ) { return; } - if ( ['other_names', 'identifiers', 'links', 'contact_details', 'sources'].indexOf(field) != -1 ) { + if ( ['other_names', 'identifiers', 'links', 'contact_details', 'sources', 'field_sources'].indexOf(field) != -1 ) { if ( _.isArray(body[field]) && body[field].length ) { var new_item = []; if ( _.isArray(item) && item.length ) { diff --git a/public/js/augmenters/source-field.js b/public/js/augmenters/source-field.js new file mode 100644 index 00000000..57482198 --- /dev/null +++ b/public/js/augmenters/source-field.js @@ -0,0 +1,15 @@ +require(['jquery'], function($) { + "use strict"; + + var linkSelector = '.js-source__link'; + var popupDisplayClass = 'source__popup--display'; + + $(function() { + $(document).on('click', linkSelector, function showSourceField(e) { + e.preventDefault(); + var displayID = $(this).attr('href'); + var $display = $(displayID); + $display.toggleClass(popupDisplayClass); + }); + }); +}); diff --git a/public/js/run-instance-admin.js b/public/js/run-instance-admin.js index 4121668d..efed4c44 100644 --- a/public/js/run-instance-admin.js +++ b/public/js/run-instance-admin.js @@ -5,7 +5,8 @@ require([ 'augmenters/migration', 'augmenters/slug-validation', 'augmenters/edit-in-place', - 'augmenters/enter-to-save' + 'augmenters/enter-to-save', + 'augmenters/source-field' ]); // PopIt editing app - load it and add bits needed diff --git a/public/sass/_people-and-organizations.scss b/public/sass/_people-and-organizations.scss index aa612cca..d7044028 100644 --- a/public/sass/_people-and-organizations.scss +++ b/public/sass/_people-and-organizations.scss @@ -178,15 +178,15 @@ $entity-photo-sidebar-width: 285px; margin: 5px 5px 0; height: 32px; } + } - .membership__delete { - @extend .pull-right; - color: #C54747; + .membership__delete, + .other_name-delete { + color: #C54747; - &:hover, - &:focus { - color: darken(#C54747, 20%); - } + &:hover, + &:focus { + color: darken(#C54747, 20%); } } @@ -312,27 +312,6 @@ $entity-photo-sidebar-width: 285px; } } -.entity-header__social { - position: absolute; - top: 32px; - right: -5px; - - .entity.editing & { - display: none; - } - - a { - font-size: 21px; - padding: 5px; - border-radius: 4px; - - &:hover { - background-color: $light-grey-background; - text-decoration: none; - } - } -} - .entity-little-edit-icon { @extend .glyphicon; @extend .glyphicon-pencil; @@ -366,7 +345,7 @@ $entity-photo-sidebar-width: 285px; .entity-details__section { display: none; - padding: 15px; + padding: 15px 0; &:first-of-type { display: block; } @@ -385,7 +364,8 @@ $entity-photo-sidebar-width: 285px; } li { - margin-bottom: 15px; // this is larger than you expect, because it also compensates for negative margin on .form-controls + margin-top: 10px; + margin-bottom: 30px; } } @@ -689,3 +669,72 @@ $entity-photo-sidebar-width: 285px; height: 5em; } } + +// Per-field sourcing +.source__popup { + display: none; + position: relative; + padding: 15px; + margin: 15px 0 20px 0; + background: #FAFAD5; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); + text-align: right; + + &:after { + content: ""; + display: block; + position: absolute; + top: -20px; + right: 15px; + border: 10px solid transparent; + border-bottom-color: #FAFAD5; + } + + input { + display: inline-block; + width: 30em; + } +} + +.source__popup--display { + display: block; +} + +.field-with-metadata { + position: relative; + padding-right: 10em; +} + +.field-with-metadata__metadata { + position: absolute; + bottom: 0; + right: 0; + + & > * { + font-size: 14px; + margin-left: 15px; + } + + a { + cursor: pointer; + } + + .glyphicon { + font-size: 12px; + } + + .socicon { + font-size: 21px; + padding: 5px; + border-radius: 4px; + + &:hover { + background-color: $light-grey-background; + text-decoration: none; + } + } +} + +.source__link--no-source { + color: #999; +}