From 00fd19b33ead56842daeb6f6a24735a8687f7744 Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Thu, 9 Apr 2015 20:58:32 -0400 Subject: Implement flash messaging for admin success/error stuff --- themes/okadmin/templates/partials/flash.liquid | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 themes/okadmin/templates/partials/flash.liquid (limited to 'themes/okadmin/templates/partials/flash.liquid') diff --git a/themes/okadmin/templates/partials/flash.liquid b/themes/okadmin/templates/partials/flash.liquid new file mode 100644 index 0000000..33b621b --- /dev/null +++ b/themes/okadmin/templates/partials/flash.liquid @@ -0,0 +1,14 @@ +{% if success %} +
+ {{success}} +
+{% elsif errors %} +
+ {% for error in errors %} +
+
{{error.message}}
+
+ {% endfor %} +
+{% endif %} + -- cgit v1.2.3-70-g09d2 From 3e96d59bfad722c77a3665971d0880623471f8c4 Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Thu, 9 Apr 2015 21:01:25 -0400 Subject: Let the client decide what message to display --- app/node_modules/okadminview/index.js | 6 +++--- themes/okadmin/templates/partials/flash.liquid | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'themes/okadmin/templates/partials/flash.liquid') diff --git a/app/node_modules/okadminview/index.js b/app/node_modules/okadminview/index.js index 9e9aacf..b8ade49 100644 --- a/app/node_modules/okadminview/index.js +++ b/app/node_modules/okadminview/index.js @@ -165,7 +165,7 @@ function OKAdminView(options) { try { resource.assertValid(data); resource.create(data).then(function(created) { - req.flash('success', 'Created ' + type); + req.flash('success', {action: 'create'}); res.redirect(303, data[resource.idField]); }).fail(errorHandler(req, res)); } catch (errors) { @@ -189,7 +189,7 @@ function OKAdminView(options) { try { resource.assertValid(data); resource.update(id, data).then(function(updated) { - req.flash('success', 'Updated ' + type); + req.flash('success', {action: 'update'}); res.redirect(303, '../' + updated[resource.idField]); }).fail(errorHandler(req, res)); } catch (errors) { @@ -209,7 +209,7 @@ function OKAdminView(options) { } else { meta.get().then(function(metadata) { resource.destroy(id).then(function() { - req.flash('success', 'Deleted ' + type); + req.flash('success', {action: 'delete'}); res.redirect(303, '../..'); }).fail(errorHandler(req, res)); }).fail(errorHandler(req, res)); diff --git a/themes/okadmin/templates/partials/flash.liquid b/themes/okadmin/templates/partials/flash.liquid index 33b621b..9cd5bac 100644 --- a/themes/okadmin/templates/partials/flash.liquid +++ b/themes/okadmin/templates/partials/flash.liquid @@ -1,6 +1,6 @@ {% if success %}
- {{success}} + {{success.action}}
{% elsif errors %}
-- cgit v1.2.3-70-g09d2 From 005bab899ab3badc7796e00a2bff90e3be1209d1 Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Thu, 9 Apr 2015 21:24:48 -0400 Subject: Fix flash message error --- themes/okadmin/templates/partials/flash.liquid | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'themes/okadmin/templates/partials/flash.liquid') diff --git a/themes/okadmin/templates/partials/flash.liquid b/themes/okadmin/templates/partials/flash.liquid index 9cd5bac..1980ab5 100644 --- a/themes/okadmin/templates/partials/flash.liquid +++ b/themes/okadmin/templates/partials/flash.liquid @@ -1,14 +1,13 @@ -{% if success %} -
- {{success.action}} -
-{% elsif errors %} -
- {% for error in errors %} -
-
{{error.message}}
-
- {% endfor %} -
-{% endif %} +
+ {% for info in success %} +
{{info.action}}
+ {% endfor %} +
+
+ {% for error in errors %} +
+
{{error.message}}
+
+ {% endfor %} +
-- cgit v1.2.3-70-g09d2