diff options
author | zsloan | 2020-03-09 15:02:41 -0500 |
---|---|---|
committer | zsloan | 2020-03-09 15:02:41 -0500 |
commit | c462a41d50f748741220adf5b125d26849c9fd4f (patch) | |
tree | f898575e95af1fac831cf9ba082c5ca53cf403ed | |
parent | 04b32f95279602da4cfb00b4f356a04eee48af51 (diff) | |
download | genenetwork2-c462a41d50f748741220adf5b125d26849c9fd4f.tar.gz |
Added the option to change collection names
Remooved a couple imports that weren't used
-rw-r--r-- | wqflask/wqflask/collect.py | 14 | ||||
-rw-r--r-- | wqflask/wqflask/templates/collections/list.html | 1 | ||||
-rw-r--r-- | wqflask/wqflask/templates/collections/view.html | 30 | ||||
-rw-r--r-- | wqflask/wqflask/user_session.py | 7 |
4 files changed, 44 insertions, 8 deletions
diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py index e5c24873..2a94e63d 100644 --- a/wqflask/wqflask/collect.py +++ b/wqflask/wqflask/collect.py @@ -225,4 +225,16 @@ def view_collection(): else: return render_template("collections/view.html", **collection_info - )
\ No newline at end of file + ) + +@app.route("/collections/change_name", methods=('POST',)) +def change_collection_name(): + params = request.form + + collection_id = params['collection_id'] + new_name = params['new_name'] + + g.user_session.change_collection_name(collection_id, new_name) + + return new_name + diff --git a/wqflask/wqflask/templates/collections/list.html b/wqflask/wqflask/templates/collections/list.html index eb3fc061..a2f1a1f7 100644 --- a/wqflask/wqflask/templates/collections/list.html +++ b/wqflask/wqflask/templates/collections/list.html @@ -2,7 +2,6 @@ {% block title %}Your Collections{% endblock %} {% block css %} <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/css/jquery.dataTables.css" /> - <link rel="stylesheet" type="text/css" href="/static/packages/DT_bootstrap/DT_bootstrap.css" /> <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/buttons.bootstrap.css" /> <link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" /> {% endblock %} diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html index fd0025d9..e5188ed8 100644 --- a/wqflask/wqflask/templates/collections/view.html +++ b/wqflask/wqflask/templates/collections/view.html @@ -9,8 +9,11 @@ <!-- Start of body --> <div class="container" style="min-width: 1250px;"> - <h1><input type="text" id="change_collection_name" style="display: none; width: 500px;" class="form-control" placeholder="{{ uc.name }}"></h1> - <h1>{{ uc.name }} <!--<button class="btn btn-default" style="margin-bottom: 5px;" id="change_collection_name">Change Collection Name</button>--></h1> + <h1> + <span id="collection_name">{{ uc.name }}</span> + <input type="text" name="new_collection_name" style="font-size: 20px; display: none; width: 500px;" class="form-control" placeholder="{{ uc.name }}"> + <button class="btn btn-default" style="display: inline;" id="change_collection_name">Change Collection Name</button> + </h1> <h3>This collection has {{ '{}'.format(numify(trait_obs|count, "record", "records")) }}</h3> <!--<hr style="height: 1px; background-color: #A9A9A9;">--> @@ -158,7 +161,6 @@ {% endblock %} {% block js %} - <script type="text/javascript" src="/static/new/js_external/md5.min.js"></script> <script type="text/javascript" src="/static/new/javascript/search_results.js"></script> <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.dataTables.min.js"></script> <script language="javascript" type="text/javascript" src="/static/new/js_external/jszip.min.js"></script> @@ -224,8 +226,28 @@ url = $(this).data("url") return submit_special(url) }); + + $("#change_collection_name").on("click", function() { + if ($('input[name=new_collection_name]').css('display') == 'none') { + $('input[name=new_collection_name]').css('display', 'inline'); + $('#collection_name').css('display', 'none'); + } else { + new_name = $('input[name=new_collection_name]').val() + $.ajax({ + type: "POST", + url: "/collections/change_name", + data: { + collection_id: $('input[name=uc_id]').val(), + new_name: new_name + } + }); + $('input[name=new_collection_name]').css('display', 'none'); + $('input[name=collection_name]').val(new_name); + $('#collection_name').text(new_name) + $('#collection_name').css('display', 'inline'); + } + }); }); - </script> diff --git a/wqflask/wqflask/user_session.py b/wqflask/wqflask/user_session.py index e19ec9df..49ad4f0a 100644 --- a/wqflask/wqflask/user_session.py +++ b/wqflask/wqflask/user_session.py @@ -169,11 +169,14 @@ class UserSession(object): return collection_dict['id'] def change_collection_name(self, collection_id, new_name): + updated_collections = [] for collection in self.user_collections: + updated_collection = collection if collection['id'] == collection_id: - collection['name'] = new_name - break + updated_collection['name'] = new_name + updated_collections.append(collection) + self.update_collections(updated_collections) return new_name def delete_collection(self, collection_id): |