mirror of https://git.48k.eu/ogcp
improve delete confirmation
Make delete confirmations show information in a manner that is easier to read. This includes delete confirmations for centers, room and folder. Messages are now more clear. Also, content table shows the type of the items (folder, room, etc.)master
parent
6a134b6337
commit
6153ca426f
|
@ -175,8 +175,7 @@ class CenterForm(FlaskForm):
|
|||
|
||||
class DeleteCenterForm(FlaskForm):
|
||||
server = HiddenField()
|
||||
center = SelectField(label=_l('Center'),
|
||||
validators=[InputRequired()])
|
||||
center = HiddenField()
|
||||
submit = SubmitField(label=_l('Submit'))
|
||||
|
||||
class RoomForm(FlaskForm):
|
||||
|
@ -194,8 +193,7 @@ class RoomForm(FlaskForm):
|
|||
|
||||
class DeleteRoomForm(FlaskForm):
|
||||
server = HiddenField()
|
||||
room = SelectField(label=_l('Room'),
|
||||
validators=[InputRequired()])
|
||||
room = HiddenField()
|
||||
submit = SubmitField(label=_l('Submit'))
|
||||
|
||||
class ImageDetailsForm(FlaskForm):
|
||||
|
|
|
@ -9,12 +9,11 @@
|
|||
{% block content %}
|
||||
|
||||
<h1 class="m-5">{{_('Delete center')}}</h1>
|
||||
{% if children %}
|
||||
<p class="text-left mx-5">The following items will be deleted</p>
|
||||
<p class="text-left mx-5">The following center and its content will be deleted</p>
|
||||
<table class="table table-hover mx-5">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>
|
||||
<th colspan="2">
|
||||
{% for x in ancestors %}
|
||||
{{x}}
|
||||
{% if not loop.last %}
|
||||
|
@ -25,19 +24,22 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-left">
|
||||
{% for c in children %}
|
||||
<tr>
|
||||
<td>
|
||||
{% if c['type'] == 'folder' %}
|
||||
📁
|
||||
{% endif %}
|
||||
{{c['name']}}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if children %}
|
||||
{% for type, elements in children.items() %}
|
||||
<tr>
|
||||
<th>{{ type }}</th>
|
||||
<td>
|
||||
{% for e in elements %}
|
||||
{{e}}
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr><td>This center is empty</td></tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
|
||||
{{ wtf.quick_form(form,
|
||||
action=url_for('action_center_delete'),
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
<h1 class="m-5">{{_('Delete room')}}</h1>
|
||||
|
||||
{% if children %}
|
||||
<p class="text-left mx-5">The following items will be deleted</p>
|
||||
<p class="text-left mx-5">The following room and its content will be deleted</p>
|
||||
<table class="table table-hover mx-5">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>
|
||||
<th colspan="2">
|
||||
{% for x in ancestors %}
|
||||
{{x}}
|
||||
{% if not loop.last %}
|
||||
|
@ -26,16 +26,20 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-left">
|
||||
{% for c in children %}
|
||||
{% if children %}
|
||||
{% for type, elements in children.items() %}
|
||||
<tr>
|
||||
<th>{{ type }}</th>
|
||||
<td>
|
||||
{% if c['type'] == 'folder' %}
|
||||
📁
|
||||
{% endif %}
|
||||
{{c['name']}}
|
||||
{% for e in elements %}
|
||||
{{e}}
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr><td>This room is empty</td></tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
|
|
|
@ -10,12 +10,11 @@
|
|||
|
||||
<h1 class="m-5">{{_('Delete folder')}}</h1>
|
||||
|
||||
{% if children %}
|
||||
<p class="text-left mx-5">The following items will be deleted</p>
|
||||
<p class="text-left mx-5">The following folder and its content will be deleted</p>
|
||||
<table class="table table-hover mx-5">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>
|
||||
<th colspan="2">
|
||||
{% for x in ancestors %}
|
||||
{{x}}
|
||||
{% if not loop.last %}
|
||||
|
@ -26,19 +25,22 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-left">
|
||||
{% for c in children %}
|
||||
<tr>
|
||||
<td>
|
||||
{% if c['type'] == 'folder' %}
|
||||
📁
|
||||
{% endif %}
|
||||
{{c['name']}}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if children %}
|
||||
{% for type, elements in children.items() %}
|
||||
<tr>
|
||||
<th>{{ type }}</th>
|
||||
<td>
|
||||
{% for e in elements %}
|
||||
{{e}}
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr><td>This folder is empty</td></tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
|
||||
{{ wtf.quick_form(form,
|
||||
method='post',
|
||||
|
|
|
@ -1222,10 +1222,9 @@ def action_folder_delete():
|
|||
form.submit.render_kw = {"formaction": url_for('action_folder_delete')}
|
||||
|
||||
scopes, unused = get_scopes()
|
||||
form.name.render_kw = {'readonly': True}
|
||||
|
||||
ancestors, children = get_scope_context(int(folder_id), 'folder', scopes)
|
||||
form.name.data = ancestors[len(ancestors)-1]
|
||||
del form.name
|
||||
|
||||
return render_template('actions/folder_delete.html', form=form,
|
||||
parent="scopes.html", scopes=scopes, ancestors=ancestors, children=children)
|
||||
|
@ -1885,9 +1884,11 @@ def get_scope_context_rec(elem_id, elem_type, scopes, ancestors):
|
|||
|
||||
def get_scope_context(elem_id, elem_type, scopes):
|
||||
ancestors, elem = get_scope_context_rec(elem_id, elem_type, scopes['scope'], [])
|
||||
children = []
|
||||
children = {}
|
||||
for c in elem['scope']:
|
||||
children.append({'name':c['name'], 'type':c['type']})
|
||||
if c['type'] not in children:
|
||||
children[c['type']] = []
|
||||
children[c['type']].append(c['name'])
|
||||
return (ancestors, children)
|
||||
|
||||
@app.route('/action/center/delete', methods=['GET', 'POST'])
|
||||
|
@ -1916,15 +1917,10 @@ def action_center_delete():
|
|||
if r.status_code != requests.codes.ok:
|
||||
return ogserver_error('scopes')
|
||||
|
||||
selected_center_id = params['scope-center']
|
||||
centers = parse_scopes_from_tree(r.json(), 'center')
|
||||
selected_center = [(center['id'], center['name']) for center in centers
|
||||
if center['id'] == int(selected_center_id)]
|
||||
form.center.choices = selected_center
|
||||
form.center.render_kw = {'readonly': True}
|
||||
form.center.data = params['scope-center']
|
||||
form.server.data = params['scope-server']
|
||||
scopes, clients = get_scopes()
|
||||
ancestors, children = get_scope_context(int(selected_center_id), 'center', scopes)
|
||||
ancestors, children = get_scope_context(int(params['scope-center']), 'center', scopes)
|
||||
return render_template('actions/delete_center.html', form=form,
|
||||
scopes=scopes, ancestors=ancestors, children=children)
|
||||
|
||||
|
@ -2000,15 +1996,11 @@ def action_room_delete():
|
|||
if r.status_code != requests.codes.ok:
|
||||
return ogserver_error('scopes')
|
||||
|
||||
rooms = parse_scopes_from_tree(r.json(), 'room')
|
||||
selected_room_id = params['scope-room']
|
||||
selected_room = [(room['id'], room['name'] + " (" + room['parent'] + ")")
|
||||
for room in rooms if room['id'] == int(selected_room_id)]
|
||||
form.room.choices = selected_room
|
||||
form.room.data = params['scope-room']
|
||||
form.room.render_kw = {'readonly': True}
|
||||
form.server.data = params['scope-server']
|
||||
scopes, clients = get_scopes()
|
||||
ancestors, children = get_scope_context(int(selected_room_id), 'room', scopes)
|
||||
ancestors, children = get_scope_context(int(params['scope-room']), 'room', scopes)
|
||||
return render_template('actions/delete_room.html', form=form,
|
||||
scopes=scopes, ancestors=ancestors, children=children)
|
||||
|
||||
|
|
Loading…
Reference in New Issue