Skip to content

Commit 623834e

Browse files
committed
initial addition of frontend status change
1 parent e934a9c commit 623834e

File tree

4 files changed

+163
-23
lines changed

4 files changed

+163
-23
lines changed

sde_collections/models/collection_choice_fields.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ class WorkflowStatusChoices(models.IntegerChoices):
101101

102102

103103
class ReindexingStatusChoices(models.IntegerChoices):
104-
REINDEXING_NOT_NEEDED = 1, "Reindexing Not Needed"
105-
REINDEXING_NEEDED_ON_DEV = 2, "Reindexing Needed on LRM Dev"
106-
REINDEXING_FINISHED_ON_DEV = 3, "Reindexing Finished on LRM Dev"
107-
REINDEXING_READY_FOR_CURATION = 4, "Ready for Curation"
108-
REINDEXING_CURATED = 5, "Curated"
109-
REINDEXING_INDEXED_ON_PROD = 6, "Indexed on Prod"
104+
REINDEXING_NOT_NEEDED = 1, "Re-Indexing Not Needed"
105+
REINDEXING_NEEDED_ON_DEV = 2, "Re-Indexing Needed on LRM Dev"
106+
REINDEXING_FINISHED_ON_DEV = 3, "Re-Indexing Finished on LRM Dev"
107+
REINDEXING_READY_FOR_CURATION = 4, "Ready for Re-Curation"
108+
REINDEXING_CURATED = 5, "Re-Curation Finished"
109+
REINDEXING_INDEXED_ON_PROD = 6, "Re-Indexed on Prod"
110110

111111
@classmethod
112112
def get_status_string(cls, value):

sde_collections/views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ def get_context_data(self, **kwargs):
227227
) # 2=regex patterns
228228
context["title_patterns"] = self.collection.titlepattern.all()
229229
context["workflow_status_choices"] = WorkflowStatusChoices
230+
context["reindexing_status_choices"] = ReindexingStatusChoices
230231
context["is_multi_division"] = self.collection.is_multi_division
231232

232233
return context

sde_indexing_helper/static/js/delta_url_list.js

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,7 @@ function setupClickHandlers() {
10391039
handleTabsClick();
10401040

10411041
handleWorkflowStatusSelect();
1042+
handleReindexingStatusSelect();
10421043
}
10431044

10441045
function getDivisionColumn() {
@@ -2093,11 +2094,11 @@ function postWorkflowStatus(collection_id, workflow_status) {
20932094
toastr.success("Workflow Status Updated!");
20942095

20952096
// Refresh page after modal closes and success message shows
2096-
setTimeout(function() {
2097+
setTimeout(function () {
20972098
window.location = window.location.href;
20982099
}, 1500);
20992100
},
2100-
error: function(xhr, status, error) {
2101+
error: function (xhr, status, error) {
21012102
$('#workflowStatusChangeModal button').blur();
21022103
$("#workflowStatusChangeModal").modal('hide');
21032104
$('.modal-backdrop').remove();
@@ -2159,3 +2160,81 @@ function handleWorkflowStatusSelect() {
21592160
});
21602161
});
21612162
}
2163+
2164+
function postReindexingStatus(collection_id, reindexing_status) {
2165+
var url = `/api/collections/${collection_id}/`;
2166+
$.ajax({
2167+
url: url,
2168+
type: "PUT",
2169+
data: {
2170+
reindexing_status: reindexing_status,
2171+
csrfmiddlewaretoken: csrftoken,
2172+
},
2173+
headers: {
2174+
"X-CSRFToken": csrftoken,
2175+
},
2176+
success: function (data) {
2177+
$('#reindexingStatusChangeModal button').blur();
2178+
$("#reindexingStatusChangeModal")
2179+
.removeClass('show')
2180+
.removeAttr('aria-hidden')
2181+
.modal('hide');
2182+
$('.modal-backdrop').remove();
2183+
$('body').removeClass('modal-open');
2184+
toastr.success("Reindexing Status Updated!");
2185+
2186+
// Refresh page after modal closes and success message shows
2187+
setTimeout(function () {
2188+
window.location = window.location.href;
2189+
}, 1500);
2190+
},
2191+
error: function (xhr, status, error) {
2192+
$('#reindexingStatusChangeModal button').blur();
2193+
$("#reindexingStatusChangeModal").modal('hide');
2194+
$('.modal-backdrop').remove();
2195+
toastr.error("Error updating reindexing status: " + error);
2196+
}
2197+
});
2198+
}
2199+
2200+
function handleReindexingStatusSelect() {
2201+
$("body").on("click", ".reindexing_status_select", function () {
2202+
$("#reindexingStatusChangeModal").modal();
2203+
var collectionName = $(".urlStyle").text();
2204+
var collection_id = $(this).data("collection-id");
2205+
var reindexing_status = $(this).attr("value");
2206+
var new_reindexing_status = $(this).text();
2207+
2208+
$(".reindexing-status-change-caption").html(
2209+
`<div>Reindexing status for <b class="bold">${collectionName}</b> will change to <b class="bold">${new_reindexing_status}</b></div>`
2210+
);
2211+
2212+
$("#reindexingStatusChangeModalForm").on("click", "button", function (event) {
2213+
event.preventDefault();
2214+
var buttonId = $(this).attr("id");
2215+
2216+
switch (buttonId) {
2217+
case "cancelreindexingStatusChange":
2218+
$("#reindexingStatusChangeModal").modal("hide");
2219+
break;
2220+
case "changeReindexingStatus":
2221+
var color_choices = {
2222+
1: "btn-light", // NOT_NEEDED
2223+
2: "btn-warning", // NEEDED
2224+
3: "btn-secondary",// FINISHED
2225+
4: "btn-info", // READY_FOR_CURATION
2226+
5: "btn-primary", // CURATED
2227+
6: "btn-success" // INDEXED_ON_PROD
2228+
};
2229+
2230+
$button = $(`#reindexing-status-button-${collection_id}`);
2231+
$button.text(new_reindexing_status);
2232+
$button.removeClass("btn-light btn-danger btn-warning btn-info btn-success btn-primary btn-secondary");
2233+
$button.addClass(color_choices[parseInt(reindexing_status)]);
2234+
postReindexingStatus(collection_id, reindexing_status);
2235+
$("#reindexingStatusChangeModal").modal("hide");
2236+
break;
2237+
}
2238+
});
2239+
});
2240+
}

sde_indexing_helper/templates/sde_collections/delta_urls_list.html

Lines changed: 75 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,56 @@
1313
{% endblock stylesheets %}
1414
{% block content %}
1515
{% csrf_token %}
16-
<div class="headerDiv">
17-
<h1 class="pageTitle">URLs</h1>
18-
<button class="btn badge {{ collection.workflow_status_button_color }} dropdown-toggle title-dropdown btn-sm"
19-
type="button"
20-
data-toggle="dropdown"
21-
aria-haspopup="true"
22-
id="workflow-status-button-{{ collection.id }}"
23-
aria-expanded="false">{{ collection.get_workflow_status_display }}</button>
24-
<div class="dropdown-menu"
25-
aria-labelledby="workflow-status-button-{{ collection.id }}">
26-
{% for choice in workflow_status_choices %}
27-
<a class="dropdown-item workflow_status_select" value="{{ choice }}" data-collection-id={{ collection.id }} >{{ choice.label }}</a>
28-
{% endfor %}
29-
</div>
30-
</div>
16+
17+
18+
<div class="headerDiv d-flex justify-content-between align-items-center">
19+
<h1 class="pageTitle mb-0">URLs</h1>
20+
21+
<div class="d-flex">
22+
<div class="btn-group mr-2">
23+
<button class="btn badge {{ collection.workflow_status_button_color }} dropdown-toggle title-dropdown btn-sm"
24+
type="button"
25+
data-toggle="dropdown"
26+
aria-haspopup="true"
27+
id="workflow-status-button-{{ collection.id }}"
28+
aria-expanded="false">
29+
{{ collection.get_workflow_status_display }}
30+
</button>
31+
<div class="dropdown-menu" aria-labelledby="workflow-status-button-{{ collection.id }}">
32+
{% for choice in workflow_status_choices %}
33+
<a class="dropdown-item workflow_status_select"
34+
value="{{ choice }}"
35+
data-collection-id="{{ collection.id }}">
36+
{{ choice.label }}
37+
</a>
38+
{% endfor %}
39+
</div>
40+
</div>
41+
42+
<div class="btn-group">
43+
<button type="button"
44+
class="btn {{ collection.reindexing_status_button_color }} dropdown-toggle btn-sm"
45+
id="reindexing-status-button-{{ collection.id }}"
46+
data-toggle="dropdown"
47+
aria-haspopup="true"
48+
aria-expanded="false">
49+
{{ collection.get_reindexing_status_display }}
50+
</button>
51+
<div class="dropdown-menu" aria-labelledby="reindexing-status-button-{{ collection.id }}">
52+
{% for choice in reindexing_status_choices.choices %}
53+
<a class="dropdown-item reindexing_status_select"
54+
href="#"
55+
value="{{ choice.0 }}"
56+
data-collection-id="{{ collection.id }}">
57+
{{ choice.1 }}
58+
</a>
59+
{% endfor %}
60+
</div>
61+
</div>
62+
</div>
63+
</div>
64+
65+
3166
<div class="deltaUrlContainer">
3267
<h3 class="whiteText deltaTitle">
3368
<!-- {{ delta_urls.count|intcomma }} Delta URLs for -->
@@ -620,6 +655,31 @@ <h5 class="modal-title">Are you sure?</h5>
620655
</div>
621656
</div>
622657

658+
<div class="modal" id="reindexingStatusChangeModal" tabindex="-1"
659+
aria-labelledby="reindexingStatusChangeModal" aria-hidden="true">
660+
<div class="modal-dialog">
661+
<div class="modal-content">
662+
<div class="modalHeader">
663+
<button type="button" class="close modal-close" data-dismiss="modal" aria-label="Close" id="closereindexingStatusChangeModal">
664+
<span aria-hidden="true">&times;</span>
665+
</button>
666+
</div>
667+
<div class="modal-body" id="modal-body">
668+
<h5 class="modal-title">Are you sure?</h5>
669+
<p class="reindexing-status-change-caption" id="caption"></p>
670+
</div>
671+
<div class="modal-footer">
672+
<form id="reindexingStatusChangeModalForm">
673+
<div class="button-wrapper">
674+
<button type="submit" class="btn btn-secondary modal-button-1" id="cancelreindexingStatusChange">No</button>
675+
<button type="submit" class="btn btn-primary modal-button-2" data-dismiss="modal" id="changeReindexingStatus">Yes</button>
676+
</div>
677+
</form>
678+
</div>
679+
</div>
680+
</div>
681+
682+
623683
{% endblock content %}
624684

625685
{% block javascripts %}

0 commit comments

Comments
 (0)