This commit is contained in:
2020-06-09 23:55:55 +00:00
parent 67b6985a5b
commit 290f806757
3 changed files with 47 additions and 43 deletions

View File

@@ -71,6 +71,8 @@
<script src="js/app.rfcases.js?rfv=6.9"></script>
<script src="js/app.rfsettings.js?rfv=6.9"></script>
<script src="js/app.ops.js?rfv=6.9"></script>
<script src="js/app.trials.js?rfv=6.9"></script>
<script src="js/app.trialEdit.js?rfv=6.9"></script>
<!-- handlebars templates -->
<script src="js/templates/templates.js?rfv=6.9"></script>

View File

@@ -7,16 +7,31 @@
/*global $, app */
app.trials = (function() {
app.trials = (function () {
"use strict";
//---------------- BEGIN MODULE SCOPE VARIABLES --------------
var stateMap = {},
configModule,
initModule;
initModule,
statusText;
//----------------- END MODULE SCOPE VARIABLES ---------------
//------------------- BEGIN UTILITY METHODS ------------------
//////////////////
//Generate a card with collapsible middle section with more details
//
statusText = function (obj) {
switch (obj.status) {
case 0:
return "NEW";
case 1:
return "approved";
case 2:
return "rejected";
default:
return "BAD STATUS: " + obj.status;
}
};
//-------------------- END UTILITY METHODS -------------------
//------------------- BEGIN EVENT HANDLERS -------------------
@@ -26,7 +41,7 @@ app.trials = (function() {
//------------------- BEGIN PUBLIC METHODS -------------------
//CONFIGMODULE
//
configModule = function(context) {
configModule = function (context) {
stateMap.context = context.context;
if (stateMap.context.params.id) {
stateMap.id = stateMap.context.params.id;
@@ -35,62 +50,49 @@ app.trials = (function() {
//INITMODULE
//
initModule = function($container) {
initModule = function ($container) {
if (typeof $container === "undefined") {
$container = $("#app-shell-main-content");
}
$container.html(Handlebars.templates["app.trials"]({}));
//case 3513
document.title = "trials";
document.title = "Trial requests";
//===================
//Get trials
app.api.get("trial/list", function(res) {
app.api.get("trial/list", function (res) {
if (res.error) {
$.gevent.publish("app-show-error", res.msg);
} else {
var $appList = $("#rf-list");
$appList.append('<ul class="list-group">');
if (res.length == 0) {
$appList.append("<h4>NO DATA :(</h4>");
} else {
$appList.append('<ul class="list-group">');
$.each(res, function(i, obj) {
if (obj.fetched) {
$.each(res, function (i, obj) {
$appList.append(
"<li class='rfc-list-item-inactive list-group-item'><a href=\"#!/trialView/" +
obj.id +
'">' +
"<span class='text-muted'>" +
(obj.trial
? "Trial "
: "") +
app.utilB.genListColumn(obj.regto) +
"&nbsp;&nbsp;" +
app.utilB.genListColumn(
app.utilB.epochToShortDate(obj.created)
) +
"</span>" +
"</a></li>"
"<li class='list-group-item'><a href=\"#!/trialEdit/" +
obj.id +
'">' +
app.utilB.genListColumn(
obj.companyName + "&nbsp;" + obj.contactName
) +
app.utilB.genListColumn(
obj.companyName + "&nbsp;" + obj.contactName
) +
"&nbsp;&nbsp;" +
app.utilB.genListColumn(
app.utilB.epochToShortDate(obj.dtRequested)
) +
"</a></li>"
);
} else {
$appList.append(
"<li class='list-group-item'><a href=\"#!/trialView/" +
obj.id +
'">' +
(obj.trial
? "Trial "
: "") +
app.utilB.genListColumn(obj.regto) +
"&nbsp;&nbsp;" +
app.utilB.genListColumn(
app.utilB.epochToShortDate(obj.created)
) +
"</a></li>"
);
}
});
});
$appList.append("</ul>");
$appList.append("</ul>");
}
}
});
//=========/trials==============

File diff suppressed because one or more lines are too long