Skip to content
This repository was archived by the owner on May 4, 2022. It is now read-only.

MUMUP-1751 : Create template-able widgets#168

Merged
vertein merged 1 commit intomasterfrom
new_template_approach
Mar 12, 2015
Merged

MUMUP-1751 : Create template-able widgets#168
vertein merged 1 commit intomasterfrom
new_template_approach

Conversation

@timlevett
Copy link
Contributor

This creates a mechanism that we can supply a JSON URL, and a template in the config, and we get smart widgets.

I have one example out of the box solution:

Step 1 - Add widget preferences to entity file

<portlet-preference>
        <name>widgetURL</name>
        <value>/portal/p/earnings-statement/max/earningStatements.resource.uP</value>
    </portlet-preference>
    <portlet-preference>
        <name>widgetType</name>
        <value>generic</value>
    </portlet-preference>
    <portlet-preference>
        <name>widgetConfig</name>
        <value><![CDATA[{"template" : "<table class='table table-striped'><tr><th>Paid</th><th>Earned</th></tr><tr ng-repeat=\"item in content.report |orderBy: ['-paid.substring(6)','-paid.substring(0,2)','-paid.substring(3,5)'] | limitTo:3\"><td><a href='/portal/p/earnings-statement/max/earning_statement.pdf.resource.uP?pP_docId={{item.docId}}' target='_blank'>{{item.paid}}</a></td><td><a href='/portal/p/earnings-statement/max/earning_statement.pdf.resource.uP?pP_docId={{item.docId}}' target='_blank'>{{item.earned}}</a></td></tr></table><a class='btn btn-default launch-app-button' href='/portal/p/earnings-statement'>See More</a>"}]]></value>
    </portlet-preference>

Pretty version of the template (note you have to escape the double quotes):

<table class='table table-striped'>
 <tr><th>Paid</th><th>Earned</th></tr>
  <tr ng-repeat=\"item in content.report |orderBy: ['-paid.substring(6)','-paid.substring(0,2)','-paid.substring(3,5)'] | limitTo:3\">
    <td><a href='/portal/p/earnings-statement/max/earning_statement.pdf.resource.uP?pP_docId={{item.docId}}' target='_blank'>{{item.paid}}</a></td>
    <td><a href='/portal/p/earnings-statement/max/earning_statement.pdf.resource.uP?pP_docId={{item.docId}}' target='_blank'>{{item.earned}}</a></td>
  </tr>
</table>
<a class='btn btn-default launch-app-button' href='/portal/p/earnings-statement'>See More</a>

Step 2, Results

image

@timlevett
Copy link
Contributor Author

@vertein
Copy link
Contributor

vertein commented Mar 12, 2015

👍 Nice.

vertein added a commit that referenced this pull request Mar 12, 2015
MUMUP-1751 : Create template-able widgets
@vertein vertein merged commit 7408d15 into master Mar 12, 2015
@timlevett
Copy link
Contributor Author

@timlevett timlevett deleted the new_template_approach branch March 12, 2015 20:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants