{% load i18n %} {% load common_text %} {% trans "This contact will be deleted permanently." as delete_message %} {% trans "Please add a name" as name_error %}
/* manually call 'exec' to initiate this nested router */ this.on('mount', function(){route.exec('')})

{% trans 'There are no contacts' %}

{% blocktrans %}The contacts should include key team members who support this {{activity_singular_lower}}{% endblocktrans %}

{% trans 'Name' %} {% trans 'Job Title' %} {% trans 'Organisation' %}
var tag = this; tag.store = stores.contactsStore; tag.edit = function(e){ route('contacts/'+e.item.contact.id); } tag.delete_contact = function(e){ function remove(){ _.remove(tag.store[tag.store.el], {id: e.item.contact.id}); tag.update(); } function del() { tag.store.save(tag, {method: 'DELETE', url:tag.store.api_urls.contact(e.item.contact.id)}).then(remove) } RiotControl.trigger('confirm-delete', { confirm: del, content: '{{ delete_message|escape }}' }); } tag.on('before-mount', function(){tag.contacts = tag.store[tag.store.el];}) tag.validated = true; tag.mixin('TabMixin');
{% trans 'back' %}

{{'contact_edit_name'|common_text_optional}}

{{'contact_edit_job_title'|common_text_optional}}

{{'contact_edit_phone'|common_text_optional}}

var tag = this; var store = stores.contactsStore; tag.contact = {}; tag.store = store; function serialize(){return _(tag.refs).mapValues(function(k){return k.value}).value()} function hasChanged(){return !_(tag.refs).every(function(v,k){ if (!tag.contact){return false} return _.toString(tag.contact[k]) === _.toString(v.value) })} function cancel(){route('contacts')} function save(){ var request; var contact; if (!hasChanged()){ cancel(); return; } contact = _.defaults(serialize(), tag.contact) contact.activity = stores.activityStore.activity.id; /* Ideally we could pick url up directly from the store. Results store does this a bit better */ var url = tag.store.api_urls.contact(contact.id); /* Basic validation */ if (contact.person_name === ''){ return window.banner_message.show('{{name_error|escape}}', 'danger'); } if (contact.id){ request = tag.store.save(tag, {data:contact, method:'PUT', url:url}) } else { request = tag.store.save(tag, {data:contact, method:'POST', url:url}) } request.done(function(response){ /* Successful "save" returns us to the list view */ var contact = _.find(store[store.el], {id:response.id}); if (!contact){ store[store.el].push(response) } else { _.assign(contact, response) } cancel() }) } tag.on('route', function(contact_id){ var contact = {}; if (contact_id === 'create'){ tag.update({contact: {}, contact_id:null}) } else { contact = _.find(tag.store[tag.store.el], {id:_.toInteger(contact_id)}, {}) || {}; tag.update({contact: contact, contact_id:contact_id}) } }) tag.cancel = cancel tag.has_changed = hasChanged tag.save = save tag.mixin('TabMixin');

{% trans 'Contacts' %}

{% trans 'Add a contact' %}