Skip to content

Commit de24212

Browse files
committed
no 'save' button in config edit - changes are submitted onChange
modified cfg rename button version bump
1 parent fcc9070 commit de24212

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

cfgs/templates/cfgs/confEdit.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575

7676
{% csrf_token %}
7777
{% form form=form %}{% endform %}
78-
<input type="submit" class="btn green" value="Save">
7978
</form>
8079
<!--</div>-->
8180
</div>
@@ -92,7 +91,6 @@
9291
{% csrf_token %}
9392
<!--{{ frm }}-->
9493
{% form form=frm %}{% endform %}
95-
<input type="submit" class="btn green" value="Save">
9694
<input type="hidden" name="_id" value="{{forloop.counter0}}">
9795
</form>
9896
</div>
@@ -142,6 +140,16 @@
142140

143141
{% endif %}
144142
{% endif %}
143+
144+
145+
<script>
146+
$(function() { $(":input").change(function() {
147+
$.post( '', $(this.form).serialize(), function(data) {
148+
alert('server response'+data);
149+
}, 'json' );
150+
})
151+
});
152+
</script>
145153
</div>
146154
</div>
147155
</div>

cfgs/templates/cfgs/confSelect.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ <h6 style="font-weight:bold">Existing configs</h6>
3333
<td style="width: 200px">
3434
<form id="cfgform{{forloop.counter0}}" style="margin: 0" action="/cfgs/rename" method="post">{% csrf_token %}
3535
<input hidden name="cfg" value="{{cfg}}">
36-
<input id="cfgname{{forloop.counter0}}" name="cfgname" type="button"
37-
class="btn blue" oldvalue={{cfg}} value={{cfg}} onclick="location.href = '/cfgs/{{cfg}}';">
38-
<i id="rename{{forloop.counter0}}" type="button" title="Rename" class="material-icons">edit</i>
36+
<i id="rename{{forloop.counter0}}" type="button"
37+
style="vertical-align: middle; color: blue"
38+
title="Rename" class="material-icons">edit</i>
39+
<input id="cfgname{{forloop.counter0}}" name="cfgname"
40+
oldvalue={{cfg}} value={{cfg}} style="width: 150px" readonly>
3941
</form>
4042
</td>
4143
<td>
@@ -60,20 +62,18 @@ <h6 style="font-weight:bold">Existing configs</h6>
6062
<script>
6163
$("#rename{{forloop.counter0}}").click(function (){
6264
var cfg = $("#cfgname{{forloop.counter0}}");
63-
var type = cfg.prop('type');
64-
cfg.toggleClass("btn blue")
65-
if (type == 'button') {
65+
var ro = cfg.prop('readonly');
66+
cfg.prop('readonly', !ro);
67+
if (ro) {
68+
$(this).css('color','red');
6669
cfg.prop('oldvalue', cfg.val());
6770
cfg.prop('type', 'text');
68-
cfg.off('click');
69-
cfg.removeAttr("onclick");
71+
cfg.focus()
7072
} else {
73+
$(this).css('color','blue');
7174
if (cfg.prop('oldvalue') != cfg.val()) {
7275
$("#cfgform{{forloop.counter0}}").submit();
7376
}
74-
cfg.prop('type', 'button');
75-
cfg.on('click');
76-
cfg.attr('onclick',"location.href = '/cfgs/{{cfg}}';");
7777
}
7878
})
7979
</script>

templates/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
</div>
103103

104104
<footer style="float: right; text-align: right; position: absolute; bottom: 0px; right: 10px;">
105-
&copy; 2018 Matthias Gorzellik | v0.2 | <a href="https://github.com/gotzl/accservermanager">GitHub</a>
105+
&copy; 2019 Matthias Gorzellik | v0.3 | <a href="https://github.com/gotzl/accservermanager">GitHub</a>
106106
</footer>
107107
</body>
108108
<html>

0 commit comments

Comments
 (0)