From 3582355f189ae7055729a1fe8a7b0ab57c67e46e Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 21 2016 20:03:25 +0000 Subject: [PATCH 1/11] Few HTML fixes on the main hubs template --- diff --git a/hubs/templates/hubs.html b/hubs/templates/hubs.html index d00c71c..55485f5 100644 --- a/hubs/templates/hubs.html +++ b/hubs/templates/hubs.html @@ -1,11 +1,12 @@ - + + {{ hub.name }} + -
@@ -37,7 +38,7 @@
- + @@ -207,9 +208,12 @@
- - - + + + - +s + + From 2bf93eb30b7896aa0a5db28d083cbd0f56cca69b Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 21 2016 20:03:25 +0000 Subject: [PATCH 2/11] Let's pass the entire widget object instead of just the id --- diff --git a/hubs/widgets/base.py b/hubs/widgets/base.py index a842baf..49ca5b2 100755 --- a/hubs/widgets/base.py +++ b/hubs/widgets/base.py @@ -50,7 +50,7 @@ def AGPLv3(name): 'widget_render', hub=widget.hub.name, idx=widget.idx) result['edit_url'] = flask.url_for( 'widget_edit_get', hub=widget.hub.name, idx=widget.idx) - result['widget_idx'] = widget.idx + result['widget'] = widget return result return inner diff --git a/hubs/widgets/templates/panel.html b/hubs/widgets/templates/panel.html index 9af630b..fb78326 100644 --- a/hubs/widgets/templates/panel.html +++ b/hubs/widgets/templates/panel.html @@ -5,10 +5,9 @@ + class="edit_widget" data-idx="{{ widget.idx }}"> -
{{ content }} From ad68ecee0e3f0ed523f74fb0cd1680ff55374d55 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 21 2016 20:03:25 +0000 Subject: [PATCH 3/11] Add endpoint to delete a widget from a hub --- diff --git a/hubs/app.py b/hubs/app.py index 8fb079b..3b60380 100755 --- a/hubs/app.py +++ b/hubs/app.py @@ -201,6 +201,22 @@ def widget_edit_post(hub, idx): return flask.redirect(flask.url_for('hub', name=hub)) +@app.route('///delete/', methods=['POST']) +@app.route('///delete', methods=['POST']) +def widget_edit_delete(hub, idx): + ''' Remove a widget from a hub. ''' + widget = get_widget(session, hub, idx) + session.delete(widget) + try: + session.commit() + except Exception as err: + flask.flash( + 'Could not delete this widget from this hub in the database '\ + 'if the error persists, please warn an admin', + 'error') + return flask.redirect(flask.url_for('hub', name=hub)) + + @app.route('/source//') @app.route('/source/') def widget_source(name): From 645396371fbb168ecd85fcbaa7f50e3f819f05fd Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 21 2016 20:03:25 +0000 Subject: [PATCH 4/11] Adjust the panel layout to show a 'Remove this widget' button --- diff --git a/hubs/static/css/style.css b/hubs/static/css/style.css index f29c893..135fdb3 100644 --- a/hubs/static/css/style.css +++ b/hubs/static/css/style.css @@ -385,3 +385,9 @@ font-size: 32pt; color: #a07cbc; } +.modal-footer button { + float: right; +} +button[name='delete_hub'] { + float: left; +} diff --git a/hubs/templates/edit.html b/hubs/templates/edit.html index f4c2718..77bd072 100644 --- a/hubs/templates/edit.html +++ b/hubs/templates/edit.html @@ -1,8 +1,8 @@ From 66e43bcfb0c7d5e59dcfa4590a80d28eaf46862c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 21 2016 20:03:25 +0000 Subject: [PATCH 5/11] Let's not return a 404 if there is nothing to configure This is required since even if there is nothing to configure we want to show the panel so that the widget can be removed from the hub if desired. --- diff --git a/hubs/app.py b/hubs/app.py index 3b60380..2cbaffe 100755 --- a/hubs/app.py +++ b/hubs/app.py @@ -156,8 +156,6 @@ def widget_json(hub, idx): @app.route('///edit', methods=['GET']) def widget_edit_get(hub, idx): widget = get_widget(session, hub, idx) - if not widget.module.data.widget_arguments: - flask.abort(404, 'Nothing to configure for this hub.') return flask.render_template( 'edit.html', hub=hub, From 25668c112ae3b407a82ea2fb768eddced45c0a26 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 21 2016 20:03:25 +0000 Subject: [PATCH 6/11] Fix placing the delete widget button on the left --- diff --git a/hubs/static/css/style.css b/hubs/static/css/style.css index 135fdb3..5b47b54 100644 --- a/hubs/static/css/style.css +++ b/hubs/static/css/style.css @@ -388,6 +388,6 @@ font-size: 32pt; .modal-footer button { float: right; } -button[name='delete_hub'] { +button[id='delete_widget'] { float: left; } diff --git a/hubs/templates/edit.html b/hubs/templates/edit.html index 77bd072..0905913 100644 --- a/hubs/templates/edit.html +++ b/hubs/templates/edit.html @@ -32,7 +32,7 @@
- From 82889d6a9f00a95e9f65fc9263202add915dce4d Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 21 2016 20:03:25 +0000 Subject: [PATCH 7/11] Show something if there is nothing to configure, but then hide the save button --- diff --git a/hubs/templates/edit.html b/hubs/templates/edit.html index 0905913..aa4f6fd 100644 --- a/hubs/templates/edit.html +++ b/hubs/templates/edit.html @@ -8,6 +8,7 @@
{% endif %} {% endfor %} + {% else %} +

Nothing to configure

+ {% endif %}
+ 'widget_edit_delete', hub=widget.hub.name, idx=widget.idx) }}" + class="modal-footer p-abs" > - From df1d18ea7cbcf2d618b0511d6602b6716464155e Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 22 2016 05:57:05 +0000 Subject: [PATCH 11/11] Add a little space in between the Save and Close button in the panel --- diff --git a/hubs/static/css/style.css b/hubs/static/css/style.css index 6905d53..5411960 100644 --- a/hubs/static/css/style.css +++ b/hubs/static/css/style.css @@ -387,6 +387,7 @@ font-size: 32pt; .modal-footer button { float: right; + margin-left: 1em; } .p-abs {