Commit cd7fc394 authored by Thomas Flemmer's avatar Thomas Flemmer

add markdownpanelto the new Motd View!

parent 0e776a88
......@@ -98,6 +98,7 @@
CREATE_NEW_MOTD: "Neue Message anlegen",
MY_MESSAGES: "Alle Nachrichten:",
NEW_MOTD: "Neue Message",
SAVE_NEW_MESSAGE: "Speichern",
/* LOAD MASK */
LOAD_MASK: "Lade Daten...",
......@@ -672,6 +673,7 @@
CREATE_NEW_MOTD: "Create New Message",
MY_MESSAGES: "All Messages:",
NEW_MOTD: "New Message",
SAVE_NEW_MESSAGE: "Save",
/* LOAD MASK */
LOAD_MASK: "Loading...",
......
......@@ -140,6 +140,7 @@ Ext.define('ARSnova.view.home.motdPanel', {
imageCls: 'icon-info thm-green',
scope: this,
handler: function () {
//ARSnova.app.getController('Question')['adHoc']();
this.newMotdPanel = Ext.create('ARSnova.view.home.NewMotdPanel');
var hTP = ARSnova.app.mainTabPanel.tabPanel.homeTabPanel;
hTP.animateActiveItem(hTP.newMotdPanel, 'slide');
......
......@@ -37,62 +37,14 @@ Ext.define('ARSnova.view.home.NewMotdPanel', {
toolbar: null,
backButton: null,
constructor: function (args) {
this.callParent(arguments);
this.mycoursesStore = new Ext.data.JsonStore({
model: 'ARSnova.model.Course'
});
var htmlEncode = window.innerWidth > 321 ? "{fullname:htmlEncode}" : "{shortname:htmlEncode}";
this.coursesFieldset = Ext.create('Ext.form.FieldSet', {
xtype: 'fieldset',
title: Messages.YOUR_COURSE_SESSIONS
});
this.mycourses = Ext.create('Ext.List', {
cls: 'myCoursesList',
store: this.mycoursesStore,
disableSelection: true,
hidden: true,
style: {
backgroundColor: 'transparent'
},
itemTpl:
'<div class="x-unsized x-button x-button-normal x-iconalign-left forwardListButton">' +
'<span class="x-button-icon x-shown courseIcon icon-prof"></span>' +
'<span class="x-button-label">' + htmlEncode + '</span></div>',
listeners: {
scope: this,
hide: function () {
this.coursesFieldset.hide();
},
show: function () {
this.coursesFieldset.show();
},
/**
* The following event is used to get the computed height of all list items and
* finally to set this value to the list DataView. In order to ensure correct rendering
* it is also necessary to get the properties "padding-top" and "padding-bottom" and
* add them to the height of the list DataView.
*/
resize: function (list, eOpts) {
var listItemsDom = list.select(".x-list .x-inner .x-inner").elements[0];
this.mycourses.setHeight(
parseInt(window.getComputedStyle(listItemsDom, "").getPropertyValue("height")) +
parseInt(window.getComputedStyle(list.dom, "").getPropertyValue("padding-top")) +
parseInt(window.getComputedStyle(list.dom, "").getPropertyValue("padding-bottom"))
);
}
}
});
/*Editor Panel*/
markdownEditPanel: null,
subject: null,
textarea: null,
saveAndContinueButton: null,
this.coursesFieldset.add(this.mycourses);
constructor: function (args) {
this.callParent(arguments);
this.backButton = Ext.create('Ext.Button', {
text: Messages.SESSIONS,
......@@ -107,16 +59,8 @@ Ext.define('ARSnova.view.home.NewMotdPanel', {
}
});
this.submitButton = Ext.create('Ext.Button', {
id: 'create-session-button',
cls: 'centerButton',
ui: 'confirm',
text: Messages.SESSION_SAVE,
handler: this.onSubmit
});
this.toolbar = Ext.create('Ext.Toolbar', {
title: Messages.NEW_SESSION,
title: Messages.NEW_MOTD,
cls: 'titlePaddingLeft',
docked: 'top',
ui: 'light',
......@@ -125,129 +69,59 @@ Ext.define('ARSnova.view.home.NewMotdPanel', {
]
});
this.markdownEditPanel = Ext.create('ARSnova.view.MarkDownEditorPanel', {
processElement: this.textarea
});
this.subject = Ext.create('Ext.field.Text', {
name: 'subject',
placeHolder: Messages.CATEGORY_PLACEHOLDER
});
this.textarea = Ext.create('Ext.plugins.ResizableTextArea', {
name: 'text',
placeHolder: Messages.FORMAT_PLACEHOLDER
});
this.saveAndContinueButton = Ext.create('Ext.Button', {
ui: 'confirm',
cls: 'saveQuestionButton',
text: Messages.SAVE_NEW_MESSAGE,
style: 'margin-top: 70px',
handler: function (button) {
/*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.add([this.toolbar, {
title: 'createSession',
title: 'createMessage',
style: {
marginTop: '15px'
},
xtype: 'formpanel',
scrollable: null,
id: 'createSession',
id: 'createMessage',
submitOnAction: false,
items: [{
xtype: 'fieldset',
items: [{
xtype: 'textfield',
name: 'name',
label: Messages.SESSION_NAME,
placeHolder: Messages.SESSION_NAME_PLACEHOLDER,
maxLength: 50,
clearIcon: true
xtype: 'fieldset',
items: [this.subject]
}, {
xtype: 'textfield',
name: 'shortName',
label: Messages.SESSION_SHORT_NAME,
placeHolder: Messages.SESSION_SHORT_NAME_PLACEHOLDER,
maxLength: 8,
clearIcon: true
xtype: 'fieldset',
items: [this.markdownEditPanel, this.textarea]
}]
}, this.submitButton, this.coursesFieldset]
},this.saveAndContinueButton] //this.submitButton, this.coursesFieldset]
}]);
this.onBefore('activate', function () {
this.getMyCourses();
this.setScrollable(true);
}, this);
},
enableInputElements: function () {
this.submitButton.enable();
this.mycourses.addListener('itemtap', this.onCourseSubmit);
},
disableInputElements: function () {
this.submitButton.disable();
this.mycourses.removeListener('itemtap', this.onCourseSubmit);
},
onSubmit: function (button) {
var panel = ARSnova.app.mainTabPanel.tabPanel.homeTabPanel.newSessionPanel,
values = this.up('panel').getValues();
panel.disableInputElements();
ARSnova.app.getController('Sessions').create({
name: values.name,
shortName: values.shortName,
newSessionPanel: panel,
creationTime: Date.now()
});
},
onCourseSubmit: function (list, index, element, e) {
var panel = ARSnova.app.mainTabPanel.tabPanel.homeTabPanel.newSessionPanel;
panel.disableInputElements();
var course = list.getStore().getAt(index);
var shortName = course.get('shortname');
if (course.get('shortname').length > 12) {
shortName = course.get('shortname');
shortName = shortName.substr(0, 7);
}
ARSnova.app.getController('Sessions').create({
name: course.get('fullname'),
shortName: shortName,
courseId: course.get('id'),
courseType: course.get('type'),
newSessionPanel: panel
});
},
getMyCourses: function () {
this.mycourses.addListener('itemtap', this.onCourseSubmit);
/* only allow auth services with fixed user names */
var allowedAuthServices = [
ARSnova.app.LOGIN_LDAP,
ARSnova.app.LOGIN_CAS
];
if (-1 === allowedAuthServices.indexOf(ARSnova.app.loginMode)) {
return;
}
var newSessionPanel = this;
ARSnova.app.courseModel.getMyCourses({
success: Ext.bind(function (response) {
if (response.responseText === "[]") {
newSessionPanel.mycourses.hide();
newSessionPanel.setScrollable(null);
} else {
newSessionPanel.mycourses.show();
newSessionPanel.setScrollable(true);
this.mycoursesStore.removeAll();
this.mycoursesStore.add(Ext.decode(response.responseText));
if (window.innerWidth > 321) {
this.mycoursesStore.sort('fullname');
} else {
this.mycoursesStore.sort('shortname');
}
}
}, this),
empty: Ext.bind(function () {
newSessionPanel.mycourses.hide();
newSessionPanel.setScrollable(null);
}, this),
unauthenticated: function () {
ARSnova.app.getController('Auth').login({
mode: ARSnova.app.loginMode
});
},
failure: function () {
console.log("my courses request failure");
}
}, (window.innerWidth > 321 ? 'name' : 'shortname'));
}
});
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