Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sx.ui.MessageBox = Ext.extend(
- Ext.panel.Panel, {
- constructor: function (config) {
- var searchParams = {
- read: "all",
- startTime: null,
- stopTime: null,
- deleteIds: null
- };
- searchParams.box = config.messageBox;
- var myself = this;
- this.fromText = Ext.create("Ext.form.field.Text", {
- text: "",
- fieldLabel: sx.label.messageFrom
- });
- this.toText = Ext.create("Ext.form.field.Text", {
- text: "",
- fieldLabel: sx.label.messageTo
- });
- this.timeText = Ext.create("Ext.form.field.Text", {
- text: "",
- fieldLabel: sx.label.messageTime
- });
- this.titleText = Ext.create("Ext.form.field.Text", {
- text: "",
- fieldLabel: sx.label.messageTopic
- });
- this.messageText = Ext.create(
- "Ext.form.field.TextArea", {
- hideLabel: true,
- height: 420,
- region: "south"
- });
- var allButton = Ext.create("Ext.button.Button", {
- text: sx.label.messageAll,
- pressed: true,
- toggleGroup: "sx.ui.MessageInbox",
- enableToggle: true,
- handler: function (but) {
- if (but.pressed) {
- searchParams.read = "ALL";
- common.updateStore(myself.store,
- searchParams)
- }
- }
- });
- var readButton = Ext.create("Ext.button.Button", {
- text: sx.label.messageRead,
- toggleGroup: "sx.ui.MessageInbox",
- enableToggle: true,
- handler: function (but) {
- if (but.pressed) {
- searchParams.read = "READ";
- common.updateStore(myself.store,
- searchParams)
- }
- }
- });
- var unReadButton = Ext.create("Ext.button.Button", {
- text: sx.label.messageUnread,
- toggleGroup: "sx.ui.MessageInbox",
- enableToggle: true,
- handler: function (but) {
- if (but.pressed) {
- searchParams.read = "UNREAD";
- common.updateStore(myself.store,
- searchParams)
- }
- }
- });
- var dateStart = Ext.create("Ext.form.field.Date", {
- hideLabel: true,
- editable: true,
- enableKeyEvents: false,
- size: 10,
- width: 100,
- listeners: {
- change: function (field, newValue, oldValue,
- eOpts) {
- searchParams.startTime = newValue;
- sx.server.updateStore(myself.store,
- searchParams)
- }
- }
- });
- var dateStop = Ext.create("Ext.form.field.Date", {
- hideLabel: true,
- editable: true,
- size: 10,
- width: 100,
- enableKeyEvents: false,
- listeners: {
- change: function (field, newValue, oldValue,
- eOpts) {
- searchParams.stopTime = newValue;
- sx.server.updateStore(myself.store,
- searchParams)
- }
- }
- });
- var searchButton = Ext.create("Ext.button.Button", {
- text: sx.label.search,
- handler: function () {
- myself.paging.moveFirst()
- }
- });
- var deleteButton = Ext.create("Ext.button.Button", {
- text: sx.label.messageDelete,
- handler: function () {
- var records = myself.messageModel.getSelection();
- if (records.length <= 0) {
- return
- }
- searchParams.deleteIds = [];
- for (var i = 0; i < records.length; i++) {
- searchParams.deleteIds[i] = records[i].get("id")
- }
- sx.server.updateStore(myself.store,
- searchParams);
- myself.paging.doRefresh();
- searchParams.deleteIds = null
- }
- });
- this.msg = new sx.ui.MessagePanel({
- border: false
- });
- this.msgWin = Ext.create("Ext.window.Window", {
- closable: true,
- closeAction: "hide",
- modal: true,
- width: 720,
- height: 240,
- items: this.msg,
- buttons: [{
- text: sx.label.messageSend,
- handler: function () {
- myself.msg.sendMsg(myself.msgWin)
- }
- }, {
- text: sx.label.cancel,
- handler: function () {
- myself.msgWin.close()
- }
- }]
- });
- var topicsTBar = ["-"];
- var buttons = [];
- if (config.messageBox == "I") {
- topicsTBar.push(allButton);
- topicsTBar.push(readButton);
- topicsTBar.push(unReadButton);
- topicsTBar.push("-");
- buttons.push({
- text: sx.label.messageReply,
- handler: function () {
- var record = myself.messageModel.getSelection();
- if (record.length > 0) {
- try {
- myself.msgWin.show();
- myself.msg.showContent({
- id: record[0].data.fromId,
- name: record[0].data.fromName
- });
- myself.msg.topicField.setValue(sx.label.messageReply + ': "' + common.digest(
- record[0].data.topic,
- 25) + '" from ' + record[0].data.fromName + "\n");
- myself.msgWin.setTitle(sx.label.mgmtMemberActionSendMsg)
- } catch (e) {}
- } else {
- Ext.Msg.alert(
- sx.label.systemMessage,
- sx.label.messageSelectItem)
- }
- }
- })
- }
- topicsTBar.push({
- xtype: "label",
- text: sx.label.messageTime + " " + sx.label.from
- });
- topicsTBar.push(dateStart);
- topicsTBar.push({
- xtype: "label",
- text: " " + sx.label.to
- });
- topicsTBar.push(dateStop);
- topicsTBar.push("-");
- topicsTBar.push(searchButton);
- topicsTBar.push("-");
- topicsTBar.push("->");
- topicsTBar.push("-");
- topicsTBar.push(deleteButton);
- topicsTBar.push("-");
- this.backToMList = Ext.create("Ext.button.Button", {
- text: sx.label.backToMsgList,
- handler: function () {
- myself.mDetail.hide();
- myself.paging.moveFirst();
- myself.mList.show()
- }
- });
- this.mDetail = Ext.create("Ext.panel.Panel", {
- region: "south",
- margins: "0 4 4 4",
- layout: "border",
- border: false,
- height: 530,
- padding: "0 5 0 5",
- split: true,
- buttons: buttons,
- hidden: true,
- fieldDefaults: {
- labelWidth: 55
- },
- items: [{
- xtype: "container",
- region: "north",
- border: false,
- height: 20,
- autoScroll: false,
- items: [this.backToMList]
- }, {
- xtype: "container",
- region: "center",
- border: false,
- layout: "column",
- height: 56,
- autoScroll: false,
- items: [{
- xtype: "container",
- columnWidth: 2 / 4,
- items: [this.titleText, this.timeText]
- }, {
- xtype: "container",
- columnWidth: 2 / 4,
- items: [this.fromText, this.toText]
- }]
- },
- this.messageText]
- });
- this.store = sx.server.getMessageTopicsStore(searchParams);
- this.store.pageSize = sx.data.member == undefined || sx.data.member.setting == undefined ? sx.server.pageSize : sx.data.member.setting.pageSize;
- this.messageModel = Ext.create(
- "Ext.selection.CheckboxModel", {
- listeners: {
- select: function (model,
- record, index, eOpts) {
- var toMsgUserL = common.getLabel(
- "sx.label.msgUser",
- record.get("toName"));
- var fromMsgUserL = common.getLabel(
- "sx.label.msgUser",
- record.get("fromName"));
- if (!toMsgUserL || toMsgUserL == "unknown") {
- myself.toText.setValue(record.get("toName"))
- } else {
- myself.toText.setValue(toMsgUserL);
- record.set("toName",
- toMsgUserL)
- }
- if (!fromMsgUserL || fromMsgUserL == "unknown") {
- myself.fromText.setValue(record.get("fromName"))
- } else {
- myself.fromText.setValue(fromMsgUserL);
- record.set("fromName",
- fromMsgUserL)
- }
- myself.timeText.setValue(record.get("mTime"));
- myself.titleText.setValue(record.get("topic"));
- myself.messageText.setValue(record.get("message"));
- if (!record.get("read")) {
- sx.server.readMessage(
- record.get("id"),
- config.messageBox);
- record.set("read",
- true);
- record.commit()
- }
- myself.lockDetails();
- myself.mList.hide();
- myself.mDetail.show()
- },
- deselect: function () {
- myself.clearDetails()
- }
- }
- });
- var sm = Ext.create("Ext.selection.CheckboxModel");
- this.paging = Ext.create("Ext.PagingToolbar", {
- beforePageText: "",
- afterPageText: "/ {0} \u9875",
- store: this.store,
- displayInfo: true,
- displayMsg: sx.label.messagePagingDisplay,
- emptyMsg: sx.label.messagePagingEmpty
- });
- this.mList = Ext.create(
- "Ext.grid.Panel", {
- region: "center",
- store: this.store,
- selModel: this.messageModel,
- margins: "4 4 0 4",
- loadMask: true,
- viewConfig: {
- stripeRows: true
- },
- columns: [{
- text: "",
- dataIndex: "read",
- width: 32,
- sortable: false,
- renderer: function (val) {
- var path = val ? "./image/outlook2003_icoRead.gif" : "./image/outlook2003_icoUnread.gif";
- return '<img src="' + path + '">'
- }
- }, {
- text: sx.label.messageTopic,
- dataIndex: "topic",
- flex: 1,
- sortable: false,
- renderer: function (
- val, metaData,
- record) {
- if (record.get("read")) {
- return val
- } else {
- return "<b>" + val + "</b>"
- }
- }
- }, {
- text: config.messageBox == "I" ? sx.label.messageFrom : sx.label.messageTo,
- dataIndex: config.messageBox == "I" ? "fromName" : "toName",
- width: 100,
- sortable: false,
- renderer: function (
- val, metaData,
- record) {
- if (!common.getLabel(
- "sx.label.msgUser",
- val) || common.getLabel(
- "sx.label.msgUser",
- val) == "unknown") {
- return val
- }
- return common.getLabel(
- "sx.label.msgUser",
- val)
- }
- }, {
- text: sx.label.messageTime,
- dataIndex: "mTime",
- width: 120,
- align: "right",
- sortable: false
- }],
- tbar: topicsTBar,
- bbar: this.paging
- });
- config.layout = "border", config.border = false;
- config.items = [this.mList, this.mDetail];
- config.itemId = "message-inbox";
- sx.ui.MessageBox.superclass.constructor.apply(this, [config])
- },
- showContent: function () {
- this.paging.moveFirst();
- this.clearDetails()
- },
- clearDetails: function () {
- this.fromText.setValue("");
- this.toText.setValue("");
- this.timeText.setValue("");
- this.titleText.setValue("");
- this.messageText.setValue("")
- },
- lockDetails: function () {
- this.fromText.setReadOnly(true);
- this.toText.setReadOnly(true);
- this.timeText.setReadOnly(true);
- this.titleText.setReadOnly(true);
- this.messageText.setReadOnly(true)
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement