From 8e9dbc8df47dc97040523f94e70360e325895786 Mon Sep 17 00:00:00 2001 From: Brian Cassidy Date: Fri, 17 Jan 2025 15:31:26 -0400 Subject: [PATCH] INTRANET-299 add message field to oclc alert display --- .../js/models/OCLCStatusModel.js | 27 +++++++++++++++---- .../js/templates/OCLCStatusTemplate.js | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/custom/modules/oclc_service_alert_status_client/js/models/OCLCStatusModel.js b/custom/modules/oclc_service_alert_status_client/js/models/OCLCStatusModel.js index 610460868..1a0cfbeaa 100644 --- a/custom/modules/oclc_service_alert_status_client/js/models/OCLCStatusModel.js +++ b/custom/modules/oclc_service_alert_status_client/js/models/OCLCStatusModel.js @@ -15,29 +15,41 @@ * @type {object} * * @prop status + * @prop message */ defaults: { status: false, + message: '', }, url: '', - message: '', alert: '', + options: '', getStatus: function() { return this.get('status'); }, + getMessage: function() { + return this.get('message'); + }, + initialize: function(status, options) { this.set('status', status); - this.message = options.message; + this.set('message', options.message); this.url = options.url; - this.alert = $(OCLCStatusTemplate({message: this.message})); + this.alert = $(OCLCStatusTemplate({message: this.getMessage()})); + this.options = options; $('#discovery-search').append(this.alert); this.fetch({ - success: function(model, response, options) { + success: function(model, response) { model.set('status', response.status); + model.set('message', this.options.message); + if (response.message) { + model.set('message', response.message); + } + $('#oclc-service-alert-message').html(this.getMessage()); model.toggleView(); } }); @@ -59,8 +71,13 @@ model = this; setInterval(function() { model.fetch({ - success: function(model, response, options) { + success: function(model, response) { model.set('status', response.status); + model.set('message', this.options.message); + if (response.message) { + model.set('message', response.message); + } + $('#oclc-service-alert-message').html(this.getMessage()); model.toggleView(); } }); diff --git a/custom/modules/oclc_service_alert_status_client/js/templates/OCLCStatusTemplate.js b/custom/modules/oclc_service_alert_status_client/js/templates/OCLCStatusTemplate.js index 096f542d4..edc2c0bf5 100644 --- a/custom/modules/oclc_service_alert_status_client/js/templates/OCLCStatusTemplate.js +++ b/custom/modules/oclc_service_alert_status_client/js/templates/OCLCStatusTemplate.js @@ -1,3 +1,3 @@ OCLCStatusTemplate = _.template( - '
<%= message %> More Info about online resource issues
' + '
<%= message %> More Info about online resource issues
' );