@@ -4,6 +4,7 @@ qx.Class.define("EventView", {
type: "singleton",

properties: {
currentOptions: {}
},

construct: function(){
@@ -61,10 +62,8 @@ qx.Class.define("EventView", {

var optionEl = $("<div />")
.addClass('option-value')
.append(that.getWording('events.'+optionValue))
.click(function(){
that.load( {filter: optionValue} );
// $(this).addClass('active');
});

that.eventFilter.append(optionEl);
@@ -88,7 +87,7 @@ qx.Class.define("EventView", {
events: eventsOnlyToday
},
{
heading: 'ebenfalls heute',
heading: null,
events: eventsAlsoToday
}
];
@@ -104,7 +103,7 @@ qx.Class.define("EventView", {
if(eventsOnDayX.length < 1) continue;
eventSetsPerDay.push(
{
heading: ( atDate.isSame(moment(), 'd') )? 'heute' : atDate.format('dddd Do MMMM'),
heading: ( atDate.isSame(moment(), 'd') )? that.getWording('term.today') : atDate.format('dddd Do MMMM'),
events: eventsOnDayX
}
);
@@ -115,7 +114,7 @@ qx.Class.define("EventView", {

eventSets = _.union(eventSetsPerDay, [
{
heading: 'ebenfalls diese Woche',
heading: that.getWording('events.alsoThisWeek'),
events: eventsAlsoThisWeek
}
]);
@@ -130,23 +129,13 @@ qx.Class.define("EventView", {
if(eventsOnDayX.length < 1) continue;
eventSetsPerDay.push(
{
heading: ( atDate.isSame(moment(), 'd') )? 'heute' : atDate.format('dddd Do MMMM'),
heading: atDate.format('dddd Do MMMM'),
events: eventsOnDayX
}
);
}

eventSets = eventSetsPerDay;

// other period events in the week
// var eventsAlsoThisWeek = APP.getDataManager().getAllEvents( {timeSpan: 'alsoThisWeek'} );

// eventSets = _.union(eventSetsPerDay, [
// {
// heading: 'ebenfalls diese Woche',
// events: eventsAlsoThisWeek
// }
// ]);
}
else {
// events = APP.getDataManager().getAllEvents();
@@ -160,10 +149,11 @@ qx.Class.define("EventView", {
load: function( options ){
var that = this;

if(options === undefined) options = { filter: 'today' };

that.reset();
that.heading.empty().append( that.getWording('events.heading') );
that.loadUIVocab();

if(options === undefined) options = { filter: 'today' };
that.setCurrentOptions(options);

var eventSets = that.setFilter( options.filter );

@@ -175,10 +165,11 @@ qx.Class.define("EventView", {
});
});

that.say('listResultsLoaded', _.flatten( _.pluck(eventSets, 'events'), true) );
that.say('listResultsLoaded', {records: _.flatten( _.pluck(eventSets, 'events'), true)} );

that.view.addClass('active');
that.isActive(true);
that.say('eventViewOpened');
},

// generic function to create a section header
@@ -206,25 +197,28 @@ qx.Class.define("EventView", {
var that = this;

// call superclass
// this.base(arguments);
this.base(arguments);

that.listen('detailViewOpened', function(){
that.hide();
});

that.listen('detailViewClosed', function(){
that.show();
if( !that.isActive() ) that.load();
if(that.isActive) that.show();
// if( !that.isActive() ) that.load();
});

that.listen('includeViewOpened', function(){
that.close();
});

// that.listen('fetchedNewData', function(){
// if( APP.getDetailView().isActive() ) that.hide();
// else that.load(that.inputField.val());
// });
that.listen('filterSet', function(){
that.close();
});

that.listen('fetchedNewData', function(){
if(that.isActive()) that.load(that.getCurrentOptions());
});

// that.listen('filterSet', function(){
// var filter = APP.getActiveFilter();
@@ -270,6 +264,8 @@ qx.Class.define("EventView", {
that['optionEl-'+optionValue].removeClass('active');
});

that.setCurrentOptions(null);

// that.show();
// that.maximize();

@@ -301,11 +297,17 @@ qx.Class.define("EventView", {
that.say('eventViewClosed');
},

changeLanguage: function(){
var that = this;
loadUIVocab: function(){
var that = this;

that.heading.empty().append( that.getWording('events.heading') );

_.each(that.filterOptions, function(optionValue){
that['optionEl-'+optionValue].empty().append(that.getWording('term.'+optionValue));
});
},

if( APP.getDetailView().isActive() ) return;
if(that.isActive()) that.load();
changeLanguage: function(){
}
}

@@ -20,7 +20,8 @@ qx.Class.define("FormView", {
feedback: {
name: 'feedback',
templateFile: 'form_feedback.html',
sendMethod: that.createFeedback
sendMethod: that.createFeedback,
urlSlag: 'feedback'
},
contact: {
name: 'contact',
@@ -30,7 +31,8 @@ qx.Class.define("FormView", {
newEntry: {
name: 'newEntry',
templateFile: 'form_newEntry.html',
sendMethod: that.createEntry
sendMethod: that.createEntry,
urlSlag: 'add'
}
});

@@ -69,6 +71,8 @@ qx.Class.define("FormView", {
load: function (type, options) {
var that = this;

if(that.getFormTypes()[type].urlSlag) APP.getRouter().setUrl(that.getFormTypes()[type].urlSlag);

// load form from html and insert
that.scrollContainer.load(that.getBaseUrl() + that.getFormTypes()[type].templateFile, function( response, status, xhr ){
if(status == "error" ){}
@@ -82,6 +86,10 @@ qx.Class.define("FormView", {
$(el).characterCounter();
});

that.view.find('input.datepicker').each(function(i, el){
$(el).val('2017-12-24');
});

// init select dropdowns
that.view.find('select').each(function(i, el){
$(el).material_select();
@@ -144,6 +152,21 @@ qx.Class.define("FormView", {
}
});

// conditional things
that.view.find('.conditional').each(function(i, el){
var dependentField = form.fields[$(el).attr('data-condition')].el;

dependentField.change(function(){
var value = ($(this).attr('type') == 'checkbox')? $(this).prop('checked').toString() : $(this).val();
if( _.contains($(el).attr('data-condition-value').split(','), value) )
$(el).show();
else
$(el).hide();
});

dependentField.trigger('change');
});

// the cancel button
that.view.find('button#cancel').first().click(function(){
that.close();
@@ -186,21 +209,22 @@ qx.Class.define("FormView", {
send: function (options) {
var that = this;

that.loading(true);
APP.loading(true);

var data = that.readForm();
console.debug(data);

// call specific send method and give callback
that.getCurrentForm().formType.sendMethod(data, options, function(){
that.getCurrentForm().formType.sendMethod(data, options, function(success){
that.createModal({
content: $('<h5>Nachricht wurde erfolgreich verschickt.</5>'),
content: success? $('<h5>'+that.getWording('form.success')+'</5>') : $('<h5>' +that.getWording('form.fail')+ '</5>'),
dismissible: true,
buttonLabel: "Schön",
buttonLabel: success? "Schön" : 'Hm!',
actions: {
ready: function(){},
close: function(){
that.close();
if(success) that.close();
else APP.loading(false);
}
}
});
@@ -219,13 +243,8 @@ qx.Class.define("FormView", {
};

APP.getDataManager().addMarketEntry(data_converted, function (response) {
if (!response.marketentry) {
alert(that.getWording('form.fail'));
that.loading(false);
return;
}

cb();
// cb(response.marketentry !== undefined);
cb(true);
});

// to github
@@ -252,6 +271,7 @@ qx.Class.define("FormView", {
message: '```\n' + data.entry.descriptionShort + '\n```\n'
+ 'für Kinder: `' + (data.entry.forChildren ? 'ja' : '-') + '`\n'
+ 'Unterstützer gesucht: `' + (data.entry.supportWanted ? 'ja' : 'nein') + '`\n'
+ 'Unterstützung Details: `' + data.additional.internalComment + '`\n'
+ 'Kontaktperson: `' + data.entry.speakerPublic + '`\n'
+ 'Sprachen: `' + data.entry.spokenLanguages + '`\n'
+ 'mail: `' + data.entry.mail + '` '
@@ -261,7 +281,7 @@ qx.Class.define("FormView", {
+ 'Ort: `' + data.location.placename + ', ' + data.location.street + ', ' + data.location.zip + ' ' + data.location.city + '`\n'
+ 'von: `' + data.entry.dateFrom + ' (' + data.entry.timeFrom + ')' + '`\n'
+ 'bis: `' + data.entry.dateTo + ' (' + data.entry.timeTo + ')' + '`\n'
+ 'Anmerkung: `' + data.additional.internalComment + '`\n'
+ 'Anmerkung: `' + data.additional.comment + '`\n'
});

// send mail to team inbox
@@ -286,6 +306,7 @@ qx.Class.define("FormView", {
+ '<tr><td style="color: gray">Beschreibung:</td><td>' + data.entry.description + '</td></tr>'
+ '<tr><td style="color: gray">für Kinder geeignet:</td><td>' + (data.entry.forChildren ? 'ja' : 'nicht explizit') + '</td></tr>'
+ '<tr><td style="color: gray">Unterstützer gesucht:</td><td>' + (data.entry.supportWanted ? 'ja' : 'nein') + '</td></tr>'
+ '<tr><td style="color: gray">Unterstützung Details:</td><td>' + data.additional.internalComment + '</td></tr>'
+ '<tr><td style="color: gray">Kontaktperson:</td><td>' + data.entry.speakerPublic + '</td></tr>'
+ '<tr><td style="color: gray">Sprachen:</td><td>' + data.entry.spokenLanguages + '</td></tr>'
+ '<tr><td style="color: gray">Mail:</td><td>' + data.entry.mail + '</td></tr>'
@@ -295,7 +316,7 @@ qx.Class.define("FormView", {
+ '<tr><td style="color: gray">Ort:</td><td>' + data.location.placename + ', ' + data.location.street + ', ' + data.location.zip + ' ' + data.location.city + '</td></tr>'
+ '<tr><td style="color: gray">von:</td><td>' + data.entry.dateFrom + ' (' + data.entry.timeFrom + ')' + '</td></tr>'
+ '<tr><td style="color: gray">bis:</td><td>' + data.entry.dateTo + ' (' + data.entry.timeTo + ')' + '</td></tr>'
+ '<tr><td style="color: gray">Anmerkung:</td><td>' + data.entry.internalComment + '</td></tr>'
+ '<tr><td style="color: gray">Anmerkung:</td><td>' + data.additional.comment + '</td></tr>'
+ '</table>';
return styles + message;
}
@@ -383,7 +404,7 @@ qx.Class.define("FormView", {

that.scrollContainer.empty();

that.loading(false);
APP.loading(false);
},

close: function () {
@@ -37,7 +37,7 @@ qx.Class.define("IntroView", {
el: (userDevice == 'mobile')? that.view : APP.getSearchView().view,
placement: (userDevice == 'mobile')? 'top' : 'right',
preAction: function(){
APP.getSearchView().results.scrollTop(0);
APP.getSearchView().scrollContainer.scrollTop(0);
APP.getSearchView().load();
APP.getSearchView().showCurtain(true);
},
@@ -110,11 +110,21 @@ qx.Class.define("MapView", {
});

that.listen('filterSet', function(){
that.loadNewData();
// that.loadNewData();
});

that.listen('listResultsLoaded', function(e){
that.loadNewData(e.customData);
if(
!e.customData.blockSyncWithMap
&& e.customData.records.length > 0
) that.loadNewData( {records: e.customData.records, fitBounds: true} );
});

that.listen('dashboardLoaded', function(e){
APP.loading(true);
that.loadNewData();
that.map.setView([ that.getViewCoords()[APP.getArea()].lat, that.getViewCoords()[APP.getArea()].lon ], that.getViewCoords()[APP.getArea()].zoom);
APP.loading(false);
});

that.listen('markersCreated', function(){
@@ -143,10 +153,6 @@ qx.Class.define("MapView", {
that.deselectMarker();
});

that.listen('searchResultsLoaded', function(){
// that.beShy(true);
});

// that.map.on('zoomend', function(){
// if(that.getSelectedMarker()){
// try{ that.layerForMainMarkers.getVisibleParent(that.getSelectedMarker()).spiderfy(); } catch(e){}
@@ -157,14 +163,16 @@ qx.Class.define("MapView", {

},

loadNewData: function( records ) {
loadNewData: function( options ) {
var that = this;

options = (typeof options !== 'undefined') ? options : {};

// reset things
that.removeMarkers();

// aplly filters
var data = (records !== undefined )? records : APP.getData().entries;
var data = (options.records !== undefined )? options.records : APP.getData().entries;

var filter = APP.getActiveFilter();

@@ -207,6 +215,7 @@ qx.Class.define("MapView", {
});

that.addMarkers(entries);
if(options.fitBounds) that.map.fitBounds(that.layerForMainMarkers.getBounds());
// that.loadFromUrl({setView: true});
},

@@ -470,7 +479,6 @@ qx.Class.define("MapView", {
// that.layerForMainMarkers.getVisibleParent(that.getSelectedMarker()).unspiderfy();
}

window.location.hash = '';
that.say('mapMarkerDeselected');
that.setSelectedMarker(null);
},
@@ -105,9 +105,11 @@ qx.Class.define("SearchView", {
if(query){
that.scrollContainer.empty();
that.loadResults(query);
APP.getRouter().setUrl('search', query);
} else {
that.reset();
that.loadDashboard();
that.say('dashboardLoaded');
}

that.inputField
@@ -139,7 +141,7 @@ qx.Class.define("SearchView", {
that.isActive(true);
that.maximize();
that.view.addClass('active');
that.say('searchResultsLoaded');
that.say('searchViewLoaded');

return that;
},
@@ -161,11 +163,12 @@ qx.Class.define("SearchView", {
// that.createSectionHeader( that.getWording('search.label.eventstoday'), function(){
// that.inputField.val('events').trigger( "input" );
// });
var highlightArea = $("<div />")

that.createSectionHeader( that.getWording('search.label.eventstoday') );

_.each(APP.getDataManager().getAllEvents( {timeSpan: 'onlyAtDayX', atDate: moment()} ).slice(0, 3), function(entry) {
var eventsToday = APP.getDataManager().getAllEvents( {timeSpan: 'onlyAtDayX', atDate: moment()} );
if(eventsToday.length == 0) eventsToday = APP.getDataManager().getAllEvents( {timeSpan: 'alsoToday', atDate: moment()} );
_.each(eventsToday.slice(0, 3), function(entry) {
that.createEntryResult( {entry: entry, targetContainertEl: that.scrollContainer} );
});

@@ -307,7 +310,7 @@ qx.Class.define("SearchView", {
// });
const entries = APP.getData().entries;

var entriesFiltered;
var entriesFiltered, blockSyncWithMap = false;

// predefined queries:
if( query.indexOf(':') >= 0 ){
@@ -453,6 +456,8 @@ qx.Class.define("SearchView", {
}
);
}

that.say('listResultsLoaded', {records: entriesFiltered, blockSyncWithMap: blockSyncWithMap} );
},

// generic function to create a section header
@@ -526,15 +531,43 @@ qx.Class.define("SearchView", {
that.listen('detailViewOpened', function(){
that.hide();
});

that.listen('detailViewClosed', function(){
that.show();
if( !that.isActive() ) that.load();
if( that.isActive() ) that.show();
else if(
!APP.getEventView().isActive()
&& !APP.getIncludeView().isActive()
) that.load();
});

that.listen('eventViewOpened', function(){
that.close();
});
that.listen('eventViewClosed', function(){
if( that.isActive() ) that.show();
else if(
!APP.getDetailView().isActive()
&& !APP.getIncludeView().isActive()
) that.load();
});

that.listen('includeViewOpened', function(){
that.close();
});
that.listen('includeViewClosed', function(){
if( that.isActive() ) that.show();
else if(
!APP.getDetailView().isActive()
&& !APP.getEventView().isActive()
) that.load();
});

that.listen('searchViewClosed', function(){
if(
!APP.getDetailView().isActive()
&& !APP.getEventView().isActive()
&& !APP.getIncludeView().isActive()
) that.load();
});

that.listen('fetchedNewData', function(){
if( APP.getDetailView().isActive() ) that.hide();
@@ -611,8 +644,6 @@ qx.Class.define("SearchView", {
that.view.removeClass('active');
that.isActive(false);

if( APP.getUserDevice() == 'desktop') that.load();

that.say('searchViewClosed');
},