CRM-19690 - crmMailing - Pick editor layout using template_type
authorTim Otten <totten@civicrm.org>
Mon, 19 Dec 2016 23:04:37 +0000 (15:04 -0800)
committerTim Otten <totten@civicrm.org>
Tue, 20 Dec 2016 04:51:21 +0000 (20:51 -0800)
commit3ac6e1072ef0434188b0f23288f12e1cbaac3916
tree35bd145835e92d237af03c0c00fe9a7d62c16dca
parent487d0f1cb7019c29b1e9909ca6d407f7122b6c8b
CRM-19690 - crmMailing - Pick editor layout using template_type

This PR allows one to display a different CiviMail composition UI depending on the `template_type`. Key details:

 1. When creating a mailing, use the path `civicrm/a/#/mailing/new` to create a mailing with the default `template_type` (aka first-preferred, by weight).
 2. When creating a mailing, use the path `civicrm/a/#/mailing/new/{template_type}` to create a mailing with a specific `template_type`.
 3. When editing a mailing, it checks the `template_type` and loads the appropriate editor.
 4. Some of the boilerplate from `2step.html`, `unified.html`, etal has been moved to `base.html`.

Note that this breaks some hidden functionality -- before, you could switch
among a few different layouts (`2step`, `unified`, `unified2`, `wizard`) by
manually editing the URL (e.g.  `civicrm/a/#/mailing/2/unified`).  Now, to
change the layout of the traditional-style mailings, you can implement a
hook, e.g.

```
function mymod_civicrm_mailingTemplateTypes(&$types) {
  foreach ($types as &$typeDef) {
    if ($typeDef['name'] === 'traditional') {
      $typeDef['editorUrl'] = '~/crmMailing/EditMailingCtrl/unified.html';
    }
  }
}
```

Relatedly, if a downstream system has found some other way to patch/hack a
replacement for the CiviMail layout, then they'll need to update it.
(Specifically, port the changes on display in `2step.html` or any of the
other layouts.).  However, this has always been a hidden trick with
unrealistic UX -- and we've refrained from documenting/institutionalizing
it...  until now.  With this PR, overloading CiviMail UI becomes a supported
feature (by way of the public-facing `hook_civicrm_mailingTypes`).
ang/crmMailing.js
ang/crmMailing/CreateMailingCtrl.js
ang/crmMailing/EditMailingCtrl.js
ang/crmMailing/EditMailingCtrl/2step.html
ang/crmMailing/EditMailingCtrl/base.html [new file with mode: 0644]
ang/crmMailing/EditMailingCtrl/unified.html
ang/crmMailing/EditMailingCtrl/unified2.html
ang/crmMailing/EditMailingCtrl/wizard.html
ang/crmMailing/EditMailingCtrl/workflow.html
ang/crmMailing/services.js
tests/phpunit/Civi/Angular/ManagerTest.php