Skip to content

Instantly share code, notes, and snippets.

@jciechowski
Created February 17, 2013 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jciechowski/4971755 to your computer and use it in GitHub Desktop.
Save jciechowski/4971755 to your computer and use it in GitHub Desktop.
/*global Ext*/
Ext.define("jit_inteviewer.controller.Main", {
extend: "Ext.app.Controller",
config: {
refs: {
main: 'mainpanel',
loginform: {
autoCreate: true,
selector: 'loginform',
xtype: 'loginform'
},
btnSubmit: "#btnSubmit",
btnLoad: '#btnLoad',
QuestionsForm: '#questionsform',
Logout: '#idLogout',
btnBack: '#ext-button-1',
},
control: {
btnSubmit: {
tap: "onSubmitNote"
},
btnLoad: {
tap: 'loadTodayInterviews'
},
btnBack: {
tap: 'showCalendar',
tap: 'addTechnologies'
},
'interviewslist': {
disclose: 'showDetail',
itemdoubletap: 'showTechnologies',
activeitemchange: 'showCalendar',
},
'questionslist': {
activeitemchange: 'showQuestions',
},
'technologieslist': {
activeitemchange: 'showCalendar',
},
Logout: {
tap: 'Logout',
},
}
},
onSubmitNote: function() {},
showDetail: function(list, record) {
var interviewFlag = "switch";
connectToHub(record.data.InterviewID); //function defintion in LiveCominication.js file
//console.log("obecne rekord data" + record.data.InterviewID );
var store3 = Ext.StoreManager.lookup('TemporalStorage');
if (store3.findRecord('ID', 1) == null){
store3.add({
interviewID: record.data.InterviewID,
personID: record.data.PersonID,
positionID: record.data.PositionID,
CVAdress: record.data.CV,
ID: "1"
});
store3.sync();
this.getMain().push({
xtype: 'questionslist',
data: record.data,
title: 'Candidate ' + record.data.Surname + ' ' + record.data.Name,
});
var store = Ext.StoreManager.lookup('QuestionsStore');
var store2 = Ext.StoreManager.lookup('InterviewsStore');
store.getProxy().setUrl('/api/question/?interviewid=' + record.data.InterviewID);
store.load();
Ext.getCmp('calendarToolbar').hide();
} else {
var previousStore = store3.findRecord('ID', 1);
if(previousStore.data.interviewID != record.data.InterviewID){
Ext.Msg.confirm(
"Confirmation",
"Are you sure you want to change interview?",
function (btn) {
if (btn === 'yes') {
//Ext.Msg.alert("You have selected Yes", "");
//jesli zmiana rozmowy - tutaj ma być zaladowana zmiana rozmowy
disconnectFromHub(previousStore.data.interviewID);
store3.add({
interviewID: record.data.InterviewID,
personID: record.data.PersonID,
positionID: record.data.PositionID,
CVAdress: record.data.CV,
ID: "1"
});
store3.sync();
this.getMain().push({
xtype: 'questionslist',
data: record.data,
title: 'Candidate ' + record.data.Surname + ' ' + record.data.Name,
});
var store = Ext.StoreManager.lookup('QuestionsStore');
var store2 = Ext.StoreManager.lookup('InterviewsStore');
store.getProxy().setUrl('/api/question/?interviewid=' + record.data.InterviewID);
store.load();
Ext.getCmp('calendarToolbar').hide();
}
else {
//Ext.Msg.alert("You have selected NO", "");
interviewFlag = "stay";
}
},
this
);
}
else{ // ta sama rozmowa, która była
store3.add({
interviewID: record.data.InterviewID,
personID: record.data.PersonID,
positionID: record.data.PositionID,
CVAdress: record.data.CV,
ID: "1"
});
store3.sync();
this.getMain().push({
xtype: 'questionslist',
data: record.data,
title: 'Candidate ' + record.data.Surname + ' ' + record.data.Name,
});
var store = Ext.StoreManager.lookup('QuestionsStore');
var store2 = Ext.StoreManager.lookup('InterviewsStore');
store.getProxy().setUrl('/api/question/?interviewid=' + record.data.InterviewID);
store.load();
Ext.getCmp('calendarToolbar').hide();
}
}
},
showTechnologiesAndPosition: function(list, record) {
//console.log(record.data);
},
showTechnologies: function(list, index, target, record, evt) {
this.getMain().push({
xtype: 'technologieslist',
data: record.data,
})
var store = Ext.StoreManager.lookup('TechnologiesStore');
store.getProxy().setUrl('/api/technologies/');
store.load();
var emptyArr = new Array();
var tmpStorage = Ext.StoreManager.lookup('TemporalStorage');
tmpStorage.add({
interviewID: record.data.InterviewID,
personID: record.data.PersonID,
ID: '1',
questions: emptyArr
});
tmpStorage.sync();
Ext.getCmp('calendarToolbar').hide();
},
showQuestions: function(record) {
var navbar = this.getMain().getNavigationBar();
var store = Ext.StoreManager.lookup('TempLogin');
var record = store.findRecord('ID', 1);
navbar.setTitle('Logged as ' + record.data.Login);
},
Logout: function(list, index, target, record, evt) {
//console.log("logout event");
// var cos = Ext.Viewport.getActiveItem('loginform');
//var cos = Ext.getCmp('jit_inteviewer.view.LoginForm');
// cos.push();
// this.redirectTo('jit_inteviewer.view.LoginForm');
this.destroy();
Ext.Viewport.setActiveItem(this.getLoginform());
},
addTechnologies: function(list, index, target, record, evt) {
var tmpStorage = Ext.StoreManager.lookup('TemporalStorage');
var newTechnologies = tmpStorage.findRecord('ID', 1);
var technologiesStore = Ext.StoreManager.lookup('TechnologiesStore');
for(var i = 0; i < newTechnologies.data.questions.length; i++) {
technologiesStore.getProxy().setUrl('/api/technologies?interviewid=' + parseInt(newTechnologies.data.interviewID, 10) + '&categoryid=' + parseInt(newTechnologies.data.questions[i], 10));
technologiesStore.load();
}
newTechnologies.data.questions = new Array();
},
loadTodayInterviews: function() {
var startDate = Ext.Date.format(new Date(), 'Ymd');
var pickedDate = Ext.getCmp('datepickerfield').getValue();
var endDate = Ext.Date.format(Ext.Date.add(pickedDate, Ext.Date.DAY, 1), 'Ymd');
var interviewStorage = Ext.StoreManager.lookup('InterviewsStore');
interviewStorage.getProxy().setUrl('/api/interviews/?startDate=' + startDate + '&endDate=' + endDate);
interviewStorage.load();
},
showCalendar: function() {
Ext.getCmp('calendarToolbar').show();
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment