Improvement for applications (backend script)
- Improved generalData fetch (ie, non subAdmin users will not request generalData that are required only by subAdmins). - Moved getTaskApplication to manage (as it is a subAdmin-only feature). - Added applyForIntern feature to allow non-intern users to apply as intern. - Added application status feature to allow subAdmins to coordinate among the applications. (setApplicationStatus and getApplicationStatus). - Added getInternApplications to view the intern applications - Improved getInternApplications and getTaskApplications to filter out processed (i.e, applications that have status set) - Renamed putTaskDetails to editTaskDetails
This commit is contained in:
parent
605a631b16
commit
f6481b5868
98
index.html
98
index.html
@ -11683,7 +11683,7 @@
|
|||||||
loader('show')
|
loader('show')
|
||||||
console.log(result)
|
console.log(result)
|
||||||
console.log(`Welcome FLO_ID: ${myFloID}`)
|
console.log(`Welcome FLO_ID: ${myFloID}`)
|
||||||
RIBC.initRIBC().then(result => {
|
RIBC.initRIBC(floGlobals.subAdmins.includes(myFloID)).then(result => {
|
||||||
console.log(result)
|
console.log(result)
|
||||||
renderAllElements()
|
renderAllElements()
|
||||||
loader('hide')
|
loader('hide')
|
||||||
@ -11695,9 +11695,9 @@
|
|||||||
|
|
||||||
const RIBC = {
|
const RIBC = {
|
||||||
|
|
||||||
initRIBC: function(){
|
initRIBC: function(isSubAdmin = false){
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Promise.all([this.refreshObjectData(), this.refreshGeneralData()])
|
Promise.all([this.refreshObjectData(), this.refreshGeneralData(isSubAdmin)])
|
||||||
.then(results => resolve(results))
|
.then(results => resolve(results))
|
||||||
.catch(error => reject(error))
|
.catch(error => reject(error))
|
||||||
})
|
})
|
||||||
@ -11712,15 +11712,30 @@
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshGeneralData: function(){
|
refreshGeneralData: function(isSubAdmin){
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var generalDataList = ["InternUpdates", "TaskApplications"]
|
var generalDataList = ["InternUpdates"]
|
||||||
|
var subAdminOnlyList = []
|
||||||
|
|
||||||
|
if(isSubAdmin){
|
||||||
|
generalDataList.push("TaskApplications", "InternAppications")
|
||||||
|
subAdminOnlyList.push("ApplicationStatus")
|
||||||
|
}
|
||||||
var promises = []
|
var promises = []
|
||||||
Promise.all(generalDataList.map(data => floCloudAPI.requestGeneralData(data)))
|
for(let data of generalDataList)
|
||||||
|
promises.push(floCloudAPI.requestGeneralData(data))
|
||||||
|
for(let data of subAdminOnlyList)
|
||||||
|
promises.push(floCloudAPI.requestGeneralData(data), {senderIDs: floGlobals.subAdmins})
|
||||||
|
|
||||||
|
Promise.all(promises)
|
||||||
.then(results => resolve('General Data Refreshed Successfully'))
|
.then(results => resolve('General Data Refreshed Successfully'))
|
||||||
.catch(error => reject(error))
|
.catch(error => reject(error))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
applyForIntern: function(name, comments = ''){
|
||||||
|
return floCloudAPI.sendGeneralData([name, comments], "InternAppications")
|
||||||
|
},
|
||||||
|
|
||||||
postInternUpdate: function(updates){
|
postInternUpdate: function(updates){
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -11741,18 +11756,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
applyForTask: function(projectCode, branch, task, comments = ''){
|
applyForTask: function(projectCode, branch, task, comments = ''){
|
||||||
return new Promise((resolve, reject) => {
|
return floCloudAPI.sendGeneralData([projectCode, branch, task, comments], "TaskApplications")
|
||||||
floCloudAPI.sendGeneralData([projectCode, branch, task, comments], "TaskApplications")
|
|
||||||
.then(results => resolve(results))
|
|
||||||
.catch(error => reject(error))
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
getTaskApplications: function(){
|
|
||||||
var filterStr = floDapps.util.getFilterString("TaskApplications")
|
|
||||||
var taskApplications = floGlobals.generalData[filterStr].map(data => {return {floID: data.sender, projectCode: data.message[0], branch: data.message[1], task: data.message[2], comments: data.message[3]}})
|
|
||||||
taskApplications = taskApplications.filter(data => data.floID in floGlobals.appObjects.RIBC.internList)
|
|
||||||
return taskApplications
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getProjectList: () => {
|
getProjectList: () => {
|
||||||
@ -11828,6 +11832,40 @@
|
|||||||
this.projectDetails[projectCode] = details
|
this.projectDetails[projectCode] = details
|
||||||
return "added project details for "+projectCode
|
return "added project details for "+projectCode
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setApplicationStatus: function(vectorClock, status){
|
||||||
|
return floCloudAPI.sendGeneralData({vectorClock, status}, "ApplicationStatus")
|
||||||
|
},
|
||||||
|
|
||||||
|
getApplicationStatus: function(vectorClock = null){
|
||||||
|
var filterStr = floDapps.util.getFilterString("ApplicationStatus")
|
||||||
|
if(vectorClock){
|
||||||
|
for(let data of floGlobals.generalData[filterStr]){
|
||||||
|
if(data.message.vectorClock === vectorClock)
|
||||||
|
return data.message.status
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
let applicationStatus = {};
|
||||||
|
for(let data of floGlobals.generalData[filterStr])
|
||||||
|
applicationStatus[data.message.vectorClock] = data.message.status
|
||||||
|
return applicationStatus
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getInternApplications: function(ignoreProcessed = true){
|
||||||
|
var filterStr = floDapps.util.getFilterString("InternAppications")
|
||||||
|
var internApplications = floGlobals.generalData[filterStr].map(data => {return {floID: data.sender, vectorClock: data.vectorClock, name: data.message[0], comments: data.message[1]}})
|
||||||
|
//filter existing interns
|
||||||
|
internApplications = internApplications.filter(data => !(data.floID in floGlobals.appObjects.RIBC.internList))
|
||||||
|
//filter processed applications
|
||||||
|
var applicationStatus = this.getApplicationStatus()
|
||||||
|
if (ignoreProcessed)
|
||||||
|
internApplications = internApplications.filter(data => !(data.vectorClock in applicationStatus))
|
||||||
|
else
|
||||||
|
internApplications.forEach(data => data.status = applicationStatus[data.vectorClock])
|
||||||
|
return internApplications
|
||||||
|
},
|
||||||
|
|
||||||
addIntern: function(floID, internName){
|
addIntern: function(floID, internName){
|
||||||
if(floID in this.internList)
|
if(floID in this.internList)
|
||||||
@ -11836,14 +11874,28 @@
|
|||||||
this.internRating[floID] = 1
|
this.internRating[floID] = 1
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
updateInternRating: function(floID, change = 0){
|
updateInternRating: function(floID, change = 0){
|
||||||
if(!(floID in this.internList))
|
if(!(floID in this.internList))
|
||||||
return "Intern not found!"
|
return "Intern not found!"
|
||||||
this.internRating[floID] += change
|
this.internRating[floID] += change
|
||||||
return "Intern rating Updated";
|
return "Intern rating Updated";
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getTaskApplications: function(ignoreProcessed = true){
|
||||||
|
var filterStr = floDapps.util.getFilterString("TaskApplications")
|
||||||
|
var taskApplications = floGlobals.generalData[filterStr].map(data => {return {floID: data.sender, vectorClock: data.vectorClock, projectCode: data.message[0], branch: data.message[1], task: data.message[2], comments: data.message[3]}})
|
||||||
|
//filter only intern applications
|
||||||
|
taskApplications = taskApplications.filter(data => data.floID in floGlobals.appObjects.RIBC.internList)
|
||||||
|
//filter processed applications
|
||||||
|
var applicationStatus = this.getApplicationStatus()
|
||||||
|
if (ignoreProcessed)
|
||||||
|
taskApplications = taskApplications.filter(data => !(data.vectorClock in applicationStatus))
|
||||||
|
else
|
||||||
|
taskApplications.forEach(data => data.status = applicationStatus[data.vectorClock])
|
||||||
|
return taskApplications
|
||||||
|
},
|
||||||
|
|
||||||
assignInternToTask: function(floID, projectCode, branch, taskNumber){
|
assignInternToTask: function(floID, projectCode, branch, taskNumber){
|
||||||
var index = projectCode + "_" + branch + "_" + taskNumber
|
var index = projectCode + "_" + branch + "_" + taskNumber
|
||||||
if(!Array.isArray(this.internsAssigned[index]))
|
if(!Array.isArray(this.internsAssigned[index]))
|
||||||
@ -12144,7 +12196,7 @@
|
|||||||
return this.projectTaskDetails[projectCode + "_" + branch + "_" + taskNumber];
|
return this.projectTaskDetails[projectCode + "_" + branch + "_" + taskNumber];
|
||||||
},
|
},
|
||||||
|
|
||||||
putTaskDetails: function (taskDetails, projectCode, branch, taskNumber) {
|
editTaskDetails: function (taskDetails, projectCode, branch, taskNumber) {
|
||||||
//add taskDetails
|
//add taskDetails
|
||||||
this.projectTaskDetails[projectCode + "_" + branch + "_" + taskNumber] = taskDetails;
|
this.projectTaskDetails[projectCode + "_" + branch + "_" + taskNumber] = taskDetails;
|
||||||
},
|
},
|
||||||
@ -12815,7 +12867,7 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
taskno = RIBC.manage.addTaskInMap(currentProject, currentBranch)
|
taskno = RIBC.manage.addTaskInMap(currentProject, currentBranch)
|
||||||
RIBC.manage.putTaskDetails({taskTitle: titleContent, taskDescription: descriptionContent}, currentProject, currentBranch, taskno)
|
RIBC.manage.editTaskDetails({taskTitle: titleContent, taskDescription: descriptionContent}, currentProject, currentBranch, taskno)
|
||||||
RIBC.manage.putTaskStatus('incomplete', currentProject, currentBranch, taskno)
|
RIBC.manage.putTaskStatus('incomplete', currentProject, currentBranch, taskno)
|
||||||
showMessage('', 'Task added to current branch')
|
showMessage('', 'Task added to current branch')
|
||||||
card.remove();
|
card.remove();
|
||||||
@ -13364,7 +13416,7 @@
|
|||||||
if(floGlobals.subAdmins.includes(myFloID)){
|
if(floGlobals.subAdmins.includes(myFloID)){
|
||||||
typeOfUser = 'admin'
|
typeOfUser = 'admin'
|
||||||
let requestsContainer = document.getElementById('requests_container');
|
let requestsContainer = document.getElementById('requests_container');
|
||||||
RIBC.getTaskApplications().forEach((app) => {
|
RIBC.manage.getTaskApplications().forEach((app) => {
|
||||||
try{
|
try{
|
||||||
if(!Array.isArray(RIBC.getAssignedInterns(app.projectCode, app.branch, app.task)) && typeof RIBC.getTaskDetails(app.projectCode, app.branch, app.task) !== 'undefined')
|
if(!Array.isArray(RIBC.getAssignedInterns(app.projectCode, app.branch, app.task)) && typeof RIBC.getTaskDetails(app.projectCode, app.branch, app.task) !== 'undefined')
|
||||||
frag.appendChild(render.requestCard(app.floID, app.projectCode, app.branch, app.task))
|
frag.appendChild(render.requestCard(app.floID, app.projectCode, app.branch, app.task))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user