Skip to content

Instantly share code, notes, and snippets.

@bangpound
Created June 6, 2016 17:13
Show Gist options
  • Save bangpound/2dfb0519ca6e8dafb3feda0ccd3219d7 to your computer and use it in GitHub Desktop.
Save bangpound/2dfb0519ca6e8dafb3feda0ccd3219d7 to your computer and use it in GitHub Desktop.
diff --git a/docroot/profiles/discoverdesign/modules/cafprojectedit/js/drupalEntity.directive.js b/docroot/profiles/discoverdesign/modules/cafprojectedit/js/drupalEntity.directive.js
index 758a6bb..6da21c0 100644
--- a/docroot/profiles/discoverdesign/modules/cafprojectedit/js/drupalEntity.directive.js
+++ b/docroot/profiles/discoverdesign/modules/cafprojectedit/js/drupalEntity.directive.js
@@ -14,6 +14,7 @@
var entityUrl = attrs['ddDrupalEntity'];
scope.alerts = [];
+ scope.mode = 'form';
scope.entity = _.find(tattoo, function (entity) {
var exp = new RegExp('^' + entityUrl + '\\?_format\\=hal_json$');
diff --git a/docroot/profiles/discoverdesign/themes/newel/templates/content/node--step.html.twig b/docroot/profiles/discoverdesign/themes/newel/templates/content/node--step.html.twig
index 364bc81..488db57 100644
--- a/docroot/profiles/discoverdesign/themes/newel/templates/content/node--step.html.twig
+++ b/docroot/profiles/discoverdesign/themes/newel/templates/content/node--step.html.twig
@@ -99,12 +99,15 @@ set title_classes = [
{% if editable %}
<form>
<dd-alert alerts="alerts"></dd-alert>
- <label for="project-step-{{ node.id }}-body-textarea-{% verbatim %}{{ delta }}{% endverbatim %}" class="form-textfield" ng-repeat="(delta, body) in entity.body">
+ <label ng-if="mode == 'form'" for="project-step-{{ node.id }}-body-textarea-{% verbatim %}{{ delta }}{% endverbatim %}" class="form-textfield" ng-repeat="(delta, body) in entity.body">
<span id="project-step-{{ node.id }}-body-{% verbatim %}{{ delta }}{% endverbatim %}" class="field-title">Description</span>
<textarea id="project-step-{{ node.id }}-body-textarea-{% verbatim %}{{ delta }}{% endverbatim %}" name="project-step-{{ node.id }}-body-textarea-{% verbatim %}{{ delta }}{% endverbatim %}" aria-labelledby="project-step-{{ node.id }}-body-{% verbatim %}{{ delta }}{% endverbatim %}" title="Description" ng-model="body.value"></textarea>
</label>
+ <div ng-if="mode == 'view'" common-mark="body.value" ng-repeat="(delta, body) in entity.body"></div>
<div class="has-buttons">
- <button ng-click="save()" ng-disabled="disabled">Save</button>
+ <button ng-show="mode == 'form'" ng-click="save()" ng-disabled="disabled">Save</button>
+ <button ng-show="mode == 'form'" ng-click="mode = 'view'">View</button>
+ <button ng-show="mode == 'view'" ng-click="mode = 'form'">Edit</button>
</div>
</form>
{{ content|without('body', 'field_subheading', 'field_icon', 'field_help_link') }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment