Commit 535be084 authored by Thomas Flemmer's avatar Thomas Flemmer

add delete button to edit message view

parent 38617e46
......@@ -96,9 +96,11 @@
MESSAGEOFTHEDAY: "Message of the Day",
MESSAGEOFTHEDAY_BUTTON: "MotD",
CREATE_NEW_MOTD: "Neue Message anlegen",
MY_MESSAGES: "Alle Nachrichten:",
NEW_MOTD: "Neue Message",
MY_MESSAGES:"Alle Nachrichten:",
NEW_MOTD: "Neue Message",
SAVE_NEW_MESSAGE: "Speichern",
EDIT_MOTD: "MotD Bearbeiten",
DELETE_MESSAGE: "Nachricht löschen",
/* LOAD MASK */
LOAD_MASK: "Lade Daten...",
......@@ -671,9 +673,11 @@
MESSAGEOFTHEDAY: "Message of the Day",
MESSAGEOFTHEDAY_BUTTON: "MotD",
CREATE_NEW_MOTD: "Create New Message",
MY_MESSAGES: "All Messages:",
NEW_MOTD: "New Message",
MY_MESSAGES: "All Messages:",
NEW_MOTD: "New Message",
SAVE_NEW_MESSAGE: "Save",
EDIT_MOTD: "Edit Message",
DELETE_MESSAGE: "Delete Message",
/* LOAD MASK */
LOAD_MASK: "Loading...",
......
......@@ -20,7 +20,6 @@ Ext.define('ARSnova.view.home.motdPanel', {
extend: 'Ext.Panel',
requires: [
'ARSnova.view.Caption',
'ARSnova.view.home.SessionList',
'Ext.ux.Fileup',
'ARSnova.view.home.SessionExportListPanel',
......@@ -115,13 +114,13 @@ Ext.define('ARSnova.view.home.motdPanel', {
this.backButton,
this.logoutButton,
this.roleIcon,
this.motdButton,
//this.motdButton,
this.changeRoleButton
]
});
this.newSessionButtonForm = Ext.create('Ext.Panel', {
this.newMessagesButtonForm = Ext.create('Ext.Panel', {
layout: {
type: 'hbox',
pack: 'center'
......@@ -150,12 +149,7 @@ Ext.define('ARSnova.view.home.motdPanel', {
]
});
this.caption = Ext.create('ARSnova.view.Caption', {
cls: 'x-form-fieldset',
style: "border-radius: 15px"
});
this.sessionsForm = Ext.create('ARSnova.view.home.SessionList', {
this.messagesForm = Ext.create('ARSnova.view.home.SessionList', {
scrollable: null,
title: Messages.MY_MESSAGES
});
......@@ -172,8 +166,8 @@ Ext.define('ARSnova.view.home.motdPanel', {
this.add([
this.toolbar,
this.newSessionButtonForm,
this.sessionsForm
this.newMessagesButtonForm,
this.messagesForm
]);
},
......@@ -188,81 +182,78 @@ Ext.define('ARSnova.view.home.motdPanel', {
ARSnova.app.sessionModel.getMySessions({
success: function (response) {
var object = "[{'name':'EU Richtlinie - Cookies','shortName':'Diese Website verwendet Cookies','keyword':'19359983','active':true,'courseType':null,'creationTime':1433844157647,'sessionType':null,'ppLevel':null,'ppSubject':null,'numQuestions':0,'numAnswers':0,'numInterposed':0,'numUnredInterposed':0,'numUnanswered':0},{'name':'test','shortName':'test','keyword':'30323397','active':true,'courseType':null,'creationTime':1433842178366,'sessionType':null,'ppLevel':null,'ppSubject':null,'numQuestions':0,'numAnswers':0,'numInterposed':0,'numUnredInterposed':0,'numUnanswered':0}]";
var object = "[{'name':'EU Richtlinie - Cookies','text':'Diese Website verwendet Cookies','keyword':'19359983','active':true,'startdate':06/06/2015,'enddate':08/06/2015,'messageType':null},{'name':'Test','text':'Das ist ein Test','keyword':'18354483','active':true,'startdate':06/06/2015,'enddate':08/06/2015,'messageType':null}]";
var sessions = Ext.decode(object);
var messages = Ext.decode(object);
console.log("response: ", response.responseText);
me.displaySessions(sessions, me.sessionsForm, hideLoadingMask);
me.displayMessages(messages, me.messagesForm, hideLoadingMask);
//me.resizeSessionButtons();
}
}, (window.innerWidth > 481 ? 'name' : 'shortname'));
}, (window.innerWidth > 481 ? 'name' : 'text'));
return promise;
},
displaySessions: function (sessions, form, hideLoadingMask) {
displayMessages: function (messages, form, hideLoadingMask) {
console.log("displaysessions");
if (sessions && sessions.length !== 0) {
if (messages && messages.length !== 0) {
form.removeAll();
form.show();
var buttonHandler = function (options) {
var hideLoadMask = ARSnova.app.showLoadMask(Messages.LOAD_MASK);
//ARSnova.app.getController('Sessions').login({
//keyword: options.config.sessionObj.keyword
//ARSnova.app.getController('messages').login({
//keyword: options.config.messageObj.keyword
//});
console.log("buttonhandler");
this.editMotdPanel = Ext.create('ARSnova.view.home.editMotdPanel');
var hTP = ARSnova.app.mainTabPanel.tabPanel.homeTabPanel;
hTP.animateActiveItem(hTP.editMotdPanel, {
type: 'slide',
direction: 'right',
direction: 'left',
duration: 700
});
hideLoadMask();
};
for (var i = 0; i < sessions.length; i++) {
var session = sessions[i];
for (var i = 0; i < messages.length; i++) {
var message = messages[i];
var icon = "icon-users thm-green";
if (session.courseType && session.courseType.length > 0) {
icon = "icon-prof";
var icon = "icon-info thm-green";
if (message.courseType && message.courseType.length > 0) {
icon = "icon-info";
}
var iconCls = icon + " courseIcon";
if (session.sessionType === 'public_pool') {
iconCls = "icon-cloud thm-green";
}
// Minimum width of 481px equals at least landscape view
var sessionkey = '<span class="sessionButtonKeyword"> (' + session.shortName + ')</span>';
var messagekey = '<span class="messageButtonKeyword"> (' + message.text + ')</span>';
var displaytext = window.innerWidth > 481 ?
Ext.util.Format.htmlEncode(session.name) + sessionkey :
Ext.util.Format.htmlEncode(session.shortName);
Ext.util.Format.htmlEncode(message.name) + messagekey :
Ext.util.Format.htmlEncode(message.text);
var sessionButton = Ext.create('ARSnova.view.MultiBadgeButton', {
var messageButton = Ext.create('ARSnova.view.MultiBadgeButton', {
xtype: 'button',
ui: 'normal',
text: displaytext,
cls: 'forwardListButton',
iconCls: iconCls,
controller: 'sessions',
controller: 'messages',
action: 'showDetails',
badgeCls: 'badgeicon',
sessionObj: session,
messageObj: message,
handler: buttonHandler
});
sessionButton.setBadge([
{badgeText: session.numInterposed, badgeCls: "feedbackQuestionsBadgeIcon"},
{badgeText: session.numQuestions, badgeCls: "questionsBadgeIcon"},
{badgeText: session.numAnswers, badgeCls: "answersBadgeIcon"}
messageButton.setBadge([
{badgeText: message.numInterposed, badgeCls: "feedbackQuestionsBadgeIcon"},
{badgeText: message.numQuestions, badgeCls: "questionsBadgeIcon"},
{badgeText: message.numAnswers, badgeCls: "answersBadgeIcon"}
]);
form.addEntry(sessionButton);
form.addEntry(messageButton);
if (!session.active) {
if (!message.active) {
this.down('button[text=' + displaytext + ']').addCls("isInactive");
}
}
......
......@@ -21,7 +21,7 @@ Ext.define('ARSnova.view.home.NewMotdPanel', {
config: {
fullscreen: true,
scrollable: null,
scrollable: true,
scroll: 'vertical'
},
......@@ -80,16 +80,16 @@ Ext.define('ARSnova.view.home.NewMotdPanel', {
});
this.startTimeDatePicker = Ext.create('Ext.field.DatePicker', {
name: 'startTimeDatePicker',
label: 'Message Startdate',
value: new Date(),
});
name: 'startTimeDatePicker',
label: 'Message Startdate',
value: new Date(),
});
this.endTimeDatePicker = Ext.create('Ext.field.DatePicker', {
name: 'endTimeDatePicker',
label: 'Message Enddate',
value: new Date(),
});
this.endTimeDatePicker = Ext.create('Ext.field.DatePicker', {
name: 'endTimeDatePicker',
label: 'Message Enddate',
value: new Date(),
});
this.saveAndContinueButton = Ext.create('Ext.Button', {
......@@ -98,7 +98,7 @@ Ext.define('ARSnova.view.home.NewMotdPanel', {
text: Messages.SAVE_NEW_MESSAGE,
style: 'margin-top: 70px',
handler: function (button) {
/*me.saveHandler(button).then(function () {
me.saveHandler(button);/*.then(function () {
Ext.toast(Messages.QUESTION_SAVED, 3000);
}).then(Ext.bind(function (response) {
me.getScrollable().getScroller().scrollTo(0, 0, true);
......@@ -132,11 +132,17 @@ Ext.define('ARSnova.view.home.NewMotdPanel', {
xtype: 'fieldset',
items: [this.endTimeDatePicker]
}]
},this.saveAndContinueButton] //this.submitButton, this.coursesFieldset]
},this.saveAndContinueButton]
}]);
},
saveHandler: function (button) {
var mainPartValues = this.mainPart.getValues();
var values = null;
//values.text = mainPartValues.text;
//values.subject = mainPartValues.subject;
console.log("save button clicked :", mainPartValues);
}
});
......@@ -21,7 +21,7 @@ Ext.define('ARSnova.view.home.editMotdPanel', {
config: {
fullscreen: true,
scrollable: null,
scrollable: true,
scroll: 'vertical'
},
......@@ -36,6 +36,8 @@ Ext.define('ARSnova.view.home.editMotdPanel', {
subject: null,
textarea: null,
saveAndContinueButton: null,
startTimeDatePicker: null,
endTimeDatePicker: null,
constructor: function (args) {
this.callParent(arguments);
......@@ -54,7 +56,7 @@ Ext.define('ARSnova.view.home.editMotdPanel', {
});
this.toolbar = Ext.create('Ext.Toolbar', {
title: "Edit",//Messages.NEW_MOTD,
title: Messages.Edit_MOTD,
cls: 'titlePaddingLeft',
docked: 'top',
ui: 'light',
......@@ -64,7 +66,7 @@ Ext.define('ARSnova.view.home.editMotdPanel', {
});
this.markdownEditPanel = Ext.create('ARSnova.view.MarkDownEditorPanel', {
processElement: this.textarea
processElement: this.textarea
});
this.subject = Ext.create('Ext.field.Text', {
......@@ -77,32 +79,45 @@ Ext.define('ARSnova.view.home.editMotdPanel', {
placeHolder: Messages.FORMAT_PLACEHOLDER
});
this.mainPart = Ext.create('Ext.form.FormPanel', {
cls: 'newQuestion',
scrollable: null,
this.startTimeDatePicker = Ext.create('Ext.field.DatePicker', {
name: 'startTimeDatePicker',
label: 'Message Startdate',
value: new Date(),
});
items: [{
xtype: 'fieldset',
items: [this.subject]
}, {
xtype: 'fieldset',
items: [this.markdownEditPanel, this.textarea]
}]
this.endTimeDatePicker = Ext.create('Ext.field.DatePicker', {
name: 'endTimeDatePicker',
label: 'Message Enddate',
value: new Date(),
});
this.saveAndContinueButton = Ext.create('Ext.Button', {
ui: 'confirm',
cls: 'saveQuestionButton',
text: Messages.SAVE_NEW_MESSAGE,
style: 'margin-top: 70px',
handler: function (button) {
this.saveHandler(button);//.then(function () {
//Ext.toast(Messages.QUESTION_SAVED, 3000);
//});
me.saveHandler(button);/*.then(function () {
Ext.toast(Messages.QUESTION_SAVED, 3000);
}).then(Ext.bind(function (response) {
me.getScrollable().getScroller().scrollTo(0, 0, true);
}, me));*/
},
scope: this
});
this.deleteMessageButton = Ext.create('ARSnova.view.MatrixButton', {
id: 'delete-session-button',
buttonConfig: 'icon',
cls: 'actionButton',
imageCls: 'icon-close thm-red',
scope: this,
handler: function () {
console.log("message delete");
}
});
this.add([this.toolbar, {
title: 'createMessage',
style: {
......@@ -113,20 +128,31 @@ Ext.define('ARSnova.view.home.editMotdPanel', {
id: 'createMessage',
submitOnAction: false,
items: [
this.mainPart,
this.saveAndContinueButton
]
items: [{
xtype: 'fieldset',
items: [{
xtype: 'fieldset',
items: [this.subject]
}, {
xtype: 'fieldset',
items: [this.markdownEditPanel, this.textarea]
}, {
xtype: 'fieldset',
items: [this.startTimeDatePicker]
}, {
xtype: 'fieldset',
items: [this.endTimeDatePicker]
}]
},this.deleteMessageButton, this.saveAndContinueButton]
}]);
},
saveHandler: function (button) {
var mainPartValues = this.mainPart.getValues();
var values = null;
saveHandler: function (button) {
var mainPartValues = this.mainPart.getValues();
var values = null;
//values.text = mainPartValues.text;
//values.subject = mainPartValues.subject;
console.log("save button clicked :", mainPartValues);
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment