From 19230d6a8732bcc28e9969a2ee2b0b215c484b96 Mon Sep 17 00:00:00 2001 From: Tim Otten <totten@civicrm.org> Date: Tue, 20 Jun 2017 14:11:31 -0700 Subject: [PATCH] AngularJS Change Sets - Update title. Add intro para. --- docs/framework/angular/modify.md | 38 +++++++++++++++++++++++++------- mkdocs.yml | 2 +- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/docs/framework/angular/modify.md b/docs/framework/angular/modify.md index cc0ca5f4..01bba605 100644 --- a/docs/framework/angular/modify.md +++ b/docs/framework/angular/modify.md @@ -1,14 +1,36 @@ -# AngularJS: Alteration +# AngularJS: Change Sets + +The [Quick Start](quickstart.md) and [Loader](loader.md) provide examples of +creating *new* screens. But what if you need to alter an *existing* screen? +CiviCRM allows third-parties to define *change sets* which programmatically +manipulate Angular content (before sending it to the client). + +## Background + +Most AngularJS tutorials focus on idealized projects where a single +developer or product-owner exercises full authority over their application. +But CiviCRM is an _ecosystem_ with a range of stakeholders, including many +developers (authoring indpendent extensions) and administrators (managing +independent deployments with independent configurations). + +... + +## tldr ```php -function example_civicrm_alterAngular($angular) { - $angular->add(\Civi\Angular\ChangeSet::create('mychanges') - ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(phpQueryObject $doc) { - $doc->find('[ng-form="crmMailingSubform"]')->attr('cat-stevens', 'ts(\'wild world\')'); - }) - ); +function mailwords_civicrm_alterAngular(\Civi\Angular\Manager $angular) { + $changeSet = \Civi\Angular\ChangeSet::create('inject_mailwords') + // ->requires('crmMailing', 'mailwords') + ->alterHtml('~/crmMailing/BlockSummary.html', + function (phpQueryObject $doc) { + $doc->find('.crm-group')->append(' + <div crm-ui-field="{name: \'subform.mailwords\', title: ts(\'Keywords\')}"> + <input crm-ui-id="subform.mailwords" class="crm-form-text" name="mailwords" ng-model="mailing.template_options.keywords"> + </div> + '); + }); + $angular->add($changeSet); } ``` - cv ang:html:show \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 3f7d2803..aaa6bb0a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -48,7 +48,7 @@ pages: - Quick Start: framework/angular/quickstart.md - File Names: framework/angular/files.md - Loader: framework/angular/loader.md - - Modifications: framework/angular/modify.md + - Change Sets: framework/angular/modify.md - Asset Builder: framework/asset-builder.md # Bootstrap: /framework/bootstrap.md # Cache: /framework/cache.md -- GitLab