GitHub user doanduyhai opened a pull request: https://github.com/apache/incubator-zeppelin/pull/745
[ZEPPELIN-697] Replace dynamic form with angular object from registry if exists ### What is this PR for? Replace dynamic form with angular object from registry if exists I updated the `Paragraph.jobRun()` method to look for existing variable from the Angular Object Registry first before displaying the dynamic form. We look for Angular object having same name: * first at paragraph scope (note id + paragraph id) * then at note scope (note id only) I did not look at **global** scope because @Leemoonsoo was mentioning somewhere that we may likely remove the global scope some day _This is a sub-task of epic **[ZEPPELIN-635]**_ ### What type of PR is it? [Improvement] ### Todos * [ ] - Code Review * [ ] - Simple Test ### Is there a relevant Jira issue? **[ZEPPELIN-697]** ### How should this be tested? * `git fetch origin pull/745/head:AngularObjectReplaceDynamicFormVar` * `git checkout AngularObjectReplaceDynamicFormVar` * `mvn clean package -DskipTests` * `bin/zeppelin-daemon.sh restart` * Create a new note * In the first paragraph, put the following code ```html %angular <form class="form-inline"> <div class="form-group"> <label for="superheroId">Super Hero: </label> <input type="text" class="form-control" id="superheroId" placeholder="Superhero name ..." ng-model="superhero"></input> </div> <button type="submit" class="btn btn-primary" ng-click="z.angularBind('superhero', superhero, {paragraph: 'PUT_HERE_PARAGRAPH_ID'})"> Bind</button> <button type="submit" class="btn btn-primary" ng-click="z.angularUnbind('superhero', {paragraph: 'PUT_HERE_PARAGRAPH_ID'})"> Unbind</button> </form> ``` * Create a second paragraph with the following code: ```scala z.getInterpreterContext().getParagraphId() ``` * Execute the second paragraph to retrieve its paragraph id * In the first paragraph, replace the text PUT_HERE_PARAGRAPH_ID by the correct paragraph id * Update the second paragraph content to ``` %md #### Super Hero of the day: **${superhero}** ``` * Now put **SpiderMan** in the input text of the first paragraph and click alternatively on **Bind** and **Unbind** ### Screenshots (if appropriate) ![angularjsreplacedynamicform](https://cloud.githubusercontent.com/assets/1532977/13290082/9cf3fbee-db12-11e5-913c-b4b8ba6a368a.gif) ### Questions: * Does the licenses files need update? --> **No** * Is there breaking changes for older versions? --> **Yes** * Does this needs documentation? --> **Yes** [ZEPPELIN-635]: https://issues.apache.org/jira/browse/ZEPPELIN-635 [ZEPPELIN-697]: https://issues.apache.org/jira/browse/ZEPPELIN-697 You can merge this pull request into a Git repository by running: $ git pull https://github.com/doanduyhai/incubator-zeppelin ZEPPELIN-697 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-zeppelin/pull/745.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #745 ---- commit f221238b6b0bdff889bc996742ac10348eb4a081 Author: DuyHai DOAN <doanduy...@gmail.com> Date: 2016-02-22T16:45:34Z [ZEPPELIN-689] Make AngularObject constructor public because of serialization issue commit bfe1a22aeae9178d4a3bf5e8d53fda525ac5f6cd Author: DuyHai DOAN <doanduy...@gmail.com> Date: 2016-02-22T22:28:11Z [ZEPPELIN-689] ZeppelinContext angular() method should look for variable using the paragraph scope then note scope commit c11b86c6815f510d71490edad311aab0484d2ac5 Author: DuyHai DOAN <doanduy...@gmail.com> Date: 2016-02-23T10:11:40Z [ZEPPELIN-689] Add Thrift RPC method angularRegistryPush() commit d81d06a85b14c4704dc5c676301ac8137eabaa0e Author: DuyHai DOAN <doanduy...@gmail.com> Date: 2016-02-23T10:01:31Z [ZEPPELIN-689] Implement z.angularBind() function commit 1592c2966b4c4678f26f09bb794516e1ac8a2475 Author: DuyHai DOAN <doanduy...@gmail.com> Date: 2016-02-23T14:20:46Z [ZEPPELIN-693] Add AngularJS z.angularUnbind() commit eeaf137ab5ec08be4d047f34e5787879ac1e649f Author: DuyHai DOAN <doanduy...@gmail.com> Date: 2016-02-23T15:07:36Z [ZEPPELIN-695] Add AngularJS z.runParagraph() commit 95d08c90411dcae3c57ba0bc0a42455b115a4b7d Author: DuyHai DOAN <doanduy...@gmail.com> Date: 2016-02-23T22:33:18Z [ZEPPELIN-696] Add notification system for AngularJS z functions commit c1cd3d0418290045201230506278b7aee22ba4dc Author: DuyHai DOAN <doanduy...@gmail.com> Date: 2016-02-24T15:12:11Z [ZEPPELIN-697] Replace dynamic form value with Angular variable if exists ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---