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.rfcases.js?rfv=6.9"></script>
<script src="js/app.rfsettings.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.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 --> <!-- handlebars templates -->
<script src="js/templates/templates.js?rfv=6.9"></script> <script src="js/templates/templates.js?rfv=6.9"></script>

View File

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

File diff suppressed because one or more lines are too long