Commit 430d18fa by Uros Spasojevic

added dialogs

finished grid
yolo
parent 392f9e31
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Ext.define('Evoksi.view.evoksi.EvoksiController', {
extend: 'Ext.app.ViewController',
alias: 'controller.evoksi',
Ext.define("Evoksi.view.evoksi.EvoksiController", {
extend: "Ext.app.ViewController",
alias: "controller.evoksi",
requires: [
'Ext.container.Container',
'Ext.layout.container.Border',
'Ext.layout.container.Fit',
'Ext.ux.GMapPanel',
'Ext.ux.IFrame',
'Ext.window.Window'
"Ext.container.Container",
"Ext.layout.container.Border",
"Ext.layout.container.Fit",
"Ext.ux.GMapPanel",
"Ext.ux.IFrame",
"Ext.window.Window"
],
config: {
listen: {
component: {
'evoksi': {
markerClick: function (marker) {
var store = this.getView().getViewModel().getStore('myStore');
evoksi: {
markerClick: function(marker) {
var store = this.getView()
.getViewModel()
.getStore("myStore");
var first = true;
if (marker.performers) {
store.loadData(marker.performers);
};
var win = Ext.create('Ext.window.Window', {
title: marker.title == "" ? "New event" : marker.title, // Marker title
}
var win = Ext.create("Ext.window.Window", {
title:
marker.title == "" ? "New event" : marker.title, // Marker title
height: 600,
width: '70%',
width: "70%",
modal: true,
layout: 'border',
layout: "border",
maximizable: false,
resizable: false,
cls: 'evoksi-window',
items: [{
xtype: 'gmappanel',
region: 'west',
cls: "evoksi-window",
items: [
{
xtype: "gmappanel",
region: "west",
split: true,
splitterResize: false,
width: 300,
......@@ -40,103 +43,194 @@ Ext.define('Evoksi.view.evoksi.EvoksiController', {
lat: marker.lat, // Marker latitude
lng: marker.lng // Marker longitude
},
markers: [{
markers: [
{
lat: marker.lat,
lng: marker.lng,
animation: google.maps.Animation.BOUNCE
}],
animation:
google.maps.Animation.BOUNCE
}
],
mapOptions: {
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeId:
google.maps.MapTypeId.ROADMAP,
zoom: 15
}
},
{
xtype: 'panel',
cls: 'evoksi-panel-body',
region: 'center',
layout: 'vbox',
items: [{
xtype: 'textfield',
fieldLabel: 'Title',
reference: 'titleField',
xtype: "panel",
cls: "evoksi-panel-body",
region: "center",
layout: "vbox",
items: [
{
xtype: "textfield",
fieldLabel: "Title",
reference: "titleField",
value: marker.title,
width: '90%'
width: "90%"
},
{
xtype: 'textarea',
fieldLabel: 'Description',
reference: 'descriptionArea',
xtype: "textarea",
fieldLabel: "Description",
reference: "descriptionArea",
value: marker.description,
width: '90%'
width: "90%"
},
{
xtype: 'grid',
reference: 'myGrid',
title: 'Performers',
xtype: "grid",
reference: "myGrid",
title: "Performers",
height: 300,
width: '90%',
width: "90%",
store: store,
columns: [{
text: 'Name',
dataIndex: 'name'
columns: [
{
text: "Name",
dataIndex: "name"
},
{
text: 'Date',
dataIndex: 'date',
text: "Date",
dataIndex: "date",
flex: 1
},
{
text: 'Time',
dataIndex: 'time',
text: "Time",
dataIndex: "time",
flex: 1
}
],
listeners: {
select: function(obj,item,index) {
var record = store.getAt(index);
var popup = Ext.create(
"Ext.panel.Panel",
{
floating: true,
centered: true,
cls: "evoksi-add-performer",
title: "Edit performer",
modal: true,
width: 300,
height: 400,
draggable: false,
maximizable: false,
items: [
{
xtype: "textfield",
fieldLabel: "Name",
reference: "name",
value: record.get("name")
},
{
xtype: "textfield",
fieldLabel: "Date",
reference: "date",
value: record.get("date")
},
{
xtype: "textfield",
fieldLabel: "Time",
reference: "time",
value: record.get("time")
}
],
buttons: [
{
text: "Save",
formBind: true,
listeners: {
click: function() {
record.beginEdit();
record.set("name", popup.items.items[0].value);
record.set("date", popup.items.items[1].value);
record.set("time", popup.items.items[2].value);
record.endEdit();
popup.hide();
}
}
},
{
text: "Cancel",
handler: function() {
popup.hide();
}
},
{
text: "Delete",
handler: function() {
function deleteStuff(btn) {
if (btn == "yes") {
store.removeAt(index);
popup.hide();
}
}
Ext.Msg.show(
{
title: "Delete performer",
msg: "Are you sure?",
buttons:Ext.Msg.YESNO,
icon: Ext.Msg.WARNING,
fn: deleteStuff
}
);
}
}
]
}
).show();
}
}
}
],
buttons: [{
text: 'Add',
handler: function () {
var popup = Ext.create('Ext.panel.Panel', {
buttons: [
{
text: "Add",
handler: function() {
var popup = Ext.create(
"Ext.panel.Panel",
{
floating: true,
centered: true,
cls: 'evoksi-add-performer',
title: 'Add performer',
cls: "evoksi-add-performer",
title: "Add performer",
modal: true,
width: 300,
height: 400,
draggable: false,
maximizable: false,
items: [{
xtype: 'textfield',
fieldLabel: 'Name',
reference: 'name'
items: [
{
xtype: "textfield",
fieldLabel: "Name",
reference: "name"
},
{
xtype: 'textfield',
fieldLabel: 'Date',
reference: 'date'
xtype: "textfield",
fieldLabel: "Date",
reference: "date"
},
{
xtype: 'textfield',
fieldLabel: 'Time',
reference: 'time'
xtype: "textfield",
fieldLabel: "Time",
reference: "time"
}
],
buttons: [{
text: 'Save',
buttons: [
{
text: "Save",
formBind: true,
listeners: {
click: function () {
click: function() {
if (first) {
store.each(function (item) {
store.each(function(item) {
var dat = {
name: item.data.name,
date: item.data.date,
time: item.data.time
};
store.insert(0, dat);
store.insert(0,dat);
});
first = false;
}
......@@ -144,28 +238,29 @@ Ext.define('Evoksi.view.evoksi.EvoksiController', {
name: popup.items.items[0].value,
date: popup.items.items[1].value,
time: popup.items.items[2].value
}
};
store.insert(0, newPerformer);
popup.hide();
}
}
},
{
text: 'Cancel',
handler: function () {
text: "Cancel",
handler: function() {
popup.hide();
}
}
]
}).show();
}
).show();
}
},
{
text: 'Update',
handler: function () {
text: "Update",
handler: function() {
var perf = [];
store.each(function (rec) {
store.each(function(rec) {
perf.push(rec.data);
});
......@@ -178,15 +273,15 @@ Ext.define('Evoksi.view.evoksi.EvoksiController', {
animation: google.maps.Animation.DROP
};
if ((marker.saved != undefined) && (marker.saved == false)) {
newMarker.access = dbref.ref().child('data').push().key
if (marker.saved != undefined && marker.saved == false) {
newMarker.access = dbref.ref().child("data").push().key;
} else {
newMarker.access = marker.access;
}
var updates = {};
updates['/data/' + newMarker.access] = newMarker;
updates["/data/" + newMarker.access] = newMarker;
dbref.ref().update(updates);
......@@ -194,8 +289,10 @@ Ext.define('Evoksi.view.evoksi.EvoksiController', {
}
},
{
text: 'Delete',
handler: function () {
text: "Delete",
handler: function() {
function deleteStuff(btn) {
if (btn == "yes") {
var i = markers.length;
var newMarkers = [];
while (i) {
......@@ -209,19 +306,29 @@ Ext.define('Evoksi.view.evoksi.EvoksiController', {
markers = newMarkers;
dbref.ref('/data/' + marker.access).remove();
dbref.ref("/data/" + marker.access).remove();
win.close();
}
}
Ext.Msg.show({
title: "Delete event",
msg: "Are you sure?",
fn: deleteStuff,
buttons: Ext.Msg.YESNO,
icon: Ext.Msg.WARNING
});
}
}
]
}
]
}).show();
},
click: function (evt) {
click: function(evt) {
var me = this,
map = me.getView(),
key = dbref.ref().child('data').push().key,
key = dbref.ref().child("data").push().key,
marker = {
access: key,
lat: evt.latLng.lat(),
......@@ -235,57 +342,66 @@ Ext.define('Evoksi.view.evoksi.EvoksiController', {
markers.push(map.addMarker(marker));
},
mapready: function () {
mapready: function() {
var me = this;
var map = me.getView();
google.maps.event.addListener(map.gmap, 'click', function (e) {
map.fireEvent('click', e);
});
google.maps.event.addListener(
map.gmap,
"click",
function(e) {
map.fireEvent("click", e);
}
);
}
}
}
}
},
showLogin: function () {
showLogin: function() {
var me = this,
map = me.getView();
var loginWindow = Ext.create('Ext.panel.Panel', {
var loginWindow = Ext.create("Ext.panel.Panel", {
floating: true,
centered: true,
cls: 'evoksi-view-login',
title: 'Login',
cls: "evoksi-view-login",
title: "Login",
modal: true,
width: 300,
height: 400,
draggable: false,
maximizable: false,
items: [{
xtype: 'textfield',
fieldLabel: 'Username'
items: [
{
xtype: "textfield",
fieldLabel: "Username"
},
{
xtype: 'textfield',
inputType: 'password',
fieldLabel: 'Password'
xtype: "textfield",
inputType: "password",
fieldLabel: "Password"
}
],
buttons: [{
text: 'Login',
buttons: [
{
text: "Login",
formBind: true,
handler: function () {
handler: function() {
var username = loginWindow.items.items[0].value;
var password = loginWindow.items.items[1].value;
if (username == 'admin' && password == 'cpAdmin01') {
if (username == "admin" && password == "cpAdmin01") {
Ext.Ajax.request({
url: dataURL,
scope: this,
success: function (data) {
success: function(data) {
var info = Ext.decode(data.responseText);
if (info != null) {
Ext.Object.each(info, function (obj, index) {
Ext.Object.each(info, function(
obj,
index
) {
markers.push(map.addMarker(index));
});
}
......@@ -293,14 +409,20 @@ Ext.define('Evoksi.view.evoksi.EvoksiController', {
});
loginWindow.hide();
} else {
Ext.Msg.show({
title: "Login failed",
msg: "Invalid username or password",
buttons: Ext.Msg.OK,
icon: Ext.Msg.ERROR
});
}
}
}]
}
]
}).show();
},
logout: function () {
logout: function() {
var i = markers.length;
while (i) {
i--;
......@@ -311,7 +433,7 @@ Ext.define('Evoksi.view.evoksi.EvoksiController', {
this.showLogin();
},
init: function () {
init: function() {
var me = this,
map = me.getView();
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
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