Skip to content

Commit

Permalink
Merge branch 'release/1.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
iperdomo committed Jul 9, 2014
2 parents b103505 + 8ee3b80 commit 148ff4e
Show file tree
Hide file tree
Showing 495 changed files with 57,135 additions and 52,044 deletions.
16 changes: 14 additions & 2 deletions Dashboard/app/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1303,25 +1303,37 @@ nav.menuTopbar ul li:last-child {
margin: 10px 15px 0 0;
text-transform: uppercase;
}
a.addGroup, a.addSurvey, a.stepBack, a.editGroupName, a.deleteGroup {
a.addGroup, a.addSurvey, a.stepBack, a.editGroupName, a.makeMonitorGroup, a.deleteGroup {
display: block;
padding: 4px 0 4px 19px;
height: 10px;
text-transform: uppercase;
font-size: 1em;
}
a.editGroupName { margin: 0 10px 0 20px; }

a.makeMonitorGroup {
display: block;
padding: 4px 0 4px 19px;
height: 10px;
text-transform: uppercase;
text-style:bold;
font-size: 1em;
}

a.editGroupName, a.makeMonitorGroup { margin: 0 10px 0 20px; }
a.addGroup {
margin: 0 0 15px 15px;
padding: 5px 0 3px 19px;
}
a.addGroup:hover, a.addSurvey:hover, a.stepBack:hover, a.editGroupName:hover, a.deleteGroup:hover, a.manageNotifications:hover { color: rgb(255,255,255); }
a.makeMonitorGroup:hover { color: rgb(36, 85, 100); }
a.addGroup { background: url(../images/addGroupIcn.png) left top no-repeat; }
a.addGroup:hover { background: url(../images/addGroupIcn.png) left bottom no-repeat; }
a.addSurvey { background: url(../images/addSurveyIcn.png) left top no-repeat; }
a.addSurvey:hover { background: url(../images/addSurveyIcn.png) left bottom no-repeat; }
a.stepBack { background: transparent url(../images/backIcn.png) left top no-repeat; }
a.stepBack:hover { background: url(../images/backIcn.png) left bottom no-repeat; }
a.makeMonitorGroup { background: transparent url(../images/copySurvey.png) left top no-repeat; }
a.editGroupName { background: transparent url(../images/editSurvey.png) left top no-repeat; }
a.editGroupName:hover { background: url(../images/editSurvey.png) left bottom no-repeat; }
a.deleteGroup { background: transparent url(../images/deleteSurvey.png) left top no-repeat; }
Expand Down
13 changes: 13 additions & 0 deletions Dashboard/app/js/lib/controllers/data-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ FLOW.surveyInstanceControl = Ember.ArrayController.create({
}
});

FLOW.surveyedLocaleControl = Ember.ArrayController.create({
sortProperties: ['collectionDate'],
sortAscending: false,
selectedSurvey: null,
content: null,
sinceArray: [],
pageNumber: 0,

populate: function () {
this.get('sinceArray').pushObject(FLOW.metaControl.get('since'));
this.set('content', FLOW.store.findQuery(FLOW.SurveyedLocale, {}));
}
});

FLOW.questionAnswerControl = Ember.ArrayController.create({
content: null,
Expand Down
12 changes: 12 additions & 0 deletions Dashboard/app/js/lib/controllers/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ FLOW.dialogControl = Ember.Object.create({
delDeviceGroup: "delDeviceGroup",
delSI: "delSI",
delSI2: "delSI2",
makeMonitor: "makeMonitor",
showDialog: false,
message: null,
header: null,
Expand Down Expand Up @@ -226,6 +227,12 @@ FLOW.dialogControl = Ember.Object.create({
this.set('message', Ember.String.loc('_are_you_sure_delete_this_data_record'));
this.set('showDialog', true);
break;

case "makeMonitor":
this.set('header', Ember.String.loc('_make_monitor_group_header'));
this.set('message', Ember.String.loc('_make_monitor_group_text'));
this.set('showDialog', true);
break;

default:
}
Expand Down Expand Up @@ -284,6 +291,11 @@ FLOW.dialogControl = Ember.Object.create({
this.set('showDialog', false);
view.deleteSI.apply(view, arguments);
break;

case "makeMonitor":
this.set('showDialog', false);
view.makeMonitorGroup.apply(view, arguments);
break;

default:
}
Expand Down
109 changes: 85 additions & 24 deletions Dashboard/app/js/lib/controllers/survey-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ FLOW.notificationOptionControl = Ember.Object.create({
label: Ember.String.loc('_link'),
value: "LINK"
}), Ember.Object.create({
label: Ember.String.loc('_attachment'),
label: "attachment",
value: "ATTACHMENT"
})
]
Expand Down Expand Up @@ -94,21 +94,51 @@ FLOW.surveyPointTypeControl = Ember.Object.create({
]
});

FLOW.surveySectorTypeControl = Ember.Object.create({
content: [
Ember.Object.create({
label: "Water and Sanitation",
value: "WASH"
}), Ember.Object.create({
label: "Education",
value: "EDUC"
}), Ember.Object.create({
label: "Economic development",
value: "ECONDEV"
}), Ember.Object.create({
label: "Health care",
value: "HEALTH"
}), Ember.Object.create({
label: "IT and Communication",
value: "ICT"
}), Ember.Object.create({
label: "Food security",
value: "FOODSEC"
}), Ember.Object.create({
label: "Other",
value: "OTHER"
})
]
});

FLOW.alwaysTrue = function () {
return true;
};

FLOW.surveyGroupControl = Ember.ArrayController.create({
sortProperties: ['code'],
sortAscending: true,
content: null,

setFilteredContent: function () {
this.set('content', FLOW.store.filter(FLOW.SurveyGroup, function (item) {
return true;
}));
setFilteredContent: function (f) {
this.set('content', FLOW.store.filter(FLOW.SurveyGroup, f));
},

// load all Survey Groups
populate: function () {
FLOW.store.find(FLOW.SurveyGroup);
this.setFilteredContent();
populate: function (f) {
var fn = (f && $.isFunction(f) && f) || FLOW.alwaysTrue;
FLOW.store.find(FLOW.SurveyGroup);
this.setFilteredContent(fn);
},

// checks if data store contains surveys within this survey group.
Expand Down Expand Up @@ -140,18 +170,6 @@ FLOW.surveyControl = Ember.ArrayController.create({
sortProperties: ['name'],
sortAscending: true,

setFilteredContent: function () {
var sgId;
if (FLOW.selectedControl.get('selectedSurveyGroup') && FLOW.selectedControl.selectedSurveyGroup.get('keyId') > 0) {
sgId = FLOW.selectedControl.selectedSurveyGroup.get('keyId');
this.set('content', FLOW.store.filter(FLOW.Survey, function (item) {
return item.get('surveyGroupId') == sgId;
}));
} else {
this.set('content', null);
}
}.observes('FLOW.selectedControl.selectedSurveyGroup'),

setPublishedContent: function () {
var sgId;
if (FLOW.selectedControl.get('selectedSurveyGroup') && FLOW.selectedControl.selectedSurveyGroup.get('keyId') > 0) {
Expand All @@ -174,12 +192,27 @@ FLOW.surveyControl = Ember.ArrayController.create({
id = FLOW.selectedControl.selectedSurveyGroup.get('keyId');
// this content is actualy not used, the data ends up in the store
// and is accessed through the filtered content above
FLOW.store.findQuery(FLOW.Survey, {
this.set('content', FLOW.store.findQuery(FLOW.Survey, {
surveyGroupId: id
});
}));
} else {
this.set('content', null);
}
}.observes('FLOW.selectedControl.selectedSurveyGroup'),

refresh: function () {
var sg = FLOW.selectedControl.get('selectedSurveyGroup');
this.set('content', FLOW.store.filter(FLOW.Survey, function (item) {
return item.get('surveyGroupId') === sg.get('keyId');
}));
},

newLocale: function () {
var newLocaleId = FLOW.selectedControl && FLOW.selectedControl.selectedSurveyGroup && FLOW.selectedControl.selectedSurveyGroup.get('newLocaleSurveyId');
if(!this.get('content') || !this.get('content').get('isLoaded')) { return; }
this.set('newLocaleSurvey', this.find(function (item) { return item.get('keyId') === newLocaleId; }));
}.observes('content.isLoaded'),

publishSurvey: function () {
var surveyId;
surveyId = FLOW.selectedControl.selectedSurvey.get('keyId');
Expand All @@ -194,6 +227,7 @@ FLOW.surveyControl = Ember.ArrayController.create({
survey = FLOW.store.find(FLOW.Survey, keyId);
survey.deleteRecord();
FLOW.store.commit();
this.refresh();
}
});

Expand Down Expand Up @@ -242,7 +276,34 @@ FLOW.questionGroupControl = Ember.ArrayController.create({
});
return allSaved;
}
}.property('content.@each.isSaving')
}.property('content.@each.isSaving'),

// execute group delete
deleteQuestionGroup: function (questionGroupId) {
var questionGroup, questionsGroupsInSurvey, sId, qgOrder;
sId = FLOW.selectedControl.selectedSurvey.get('keyId');
questionGroup = FLOW.store.find(FLOW.QuestionGroup, questionGroupId);
qgOrder = questionGroup.get('order');

questionGroup.deleteRecord();

// restore order of remaining groups
questionGroupsInSurvey = FLOW.store.filter(FLOW.QuestionGroup, function (item) {
return item.get('surveyId') == sId;
});

// restore order
questionGroupsInSurvey.forEach(function (item) {
if (item.get('order') > qgOrder) {
item.set('order', item.get('order') - 1);
}
});

// restore order in case the order has gone haywire
FLOW.questionControl.restoreOrder(questionGroupsInSurvey);
FLOW.selectedControl.selectedSurvey.set('status', 'NOT_PUBLISHED');
FLOW.store.commit();
}
});


Expand Down Expand Up @@ -917,7 +978,7 @@ FLOW.translationControl = Ember.ArrayController.create({
}
});
if (unsaved){
FLOW.dialogControl.set('activeAction', 'ignore');
FLOW.dialogControl.set('activeAction', 'ignore');
FLOW.dialogControl.set('header', Ember.String.loc('_unsaved_translations_present'));
FLOW.dialogControl.set('message', Ember.String.loc('_unsaved_translations_present_text'));
FLOW.dialogControl.set('showCANCEL', false);
Expand Down
14 changes: 14 additions & 0 deletions Dashboard/app/js/lib/models/FLOWrest-adapter-v2-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ DS.FLOWRESTAdapter = DS.RESTAdapter.extend({
return;
}

if (status === 'preflight-delete-questiongroup') {
if (msg === 'can_delete') {
// do deletion
FLOW.questionGroupControl.deleteQuestionGroup(keyId);
} else {
FLOW.dialogControl.set('activeAction', 'ignore');
FLOW.dialogControl.set('header', Ember.String.loc('_cannot_delete_questiongroup'));
FLOW.dialogControl.set('message', Ember.String.loc('_cannot_delete_questiongroup_text'));
FLOW.dialogControl.set('showCANCEL', false);
FLOW.dialogControl.set('showDialog', true);
}
return;
}

if (status === 'preflight-delete-survey') {
if (msg === 'can_delete') {
// do deletion
Expand Down
19 changes: 15 additions & 4 deletions Dashboard/app/js/lib/models/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ FLOW.SurveyGroup = FLOW.BaseModel.extend({
createdDateTime: DS.attr('string', {
defaultValue: ''
}),
monitoringGroup: DS.attr('boolean', {
defaultValue: false
}),
newLocaleSurveyId: DS.attr('number'),
lastUpdateDateTime: DS.attr('string', {
defaultValue: ''
}),
Expand Down Expand Up @@ -104,6 +108,12 @@ FLOW.Question = FLOW.BaseModel.extend({
allowOtherFlag: DS.attr('boolean', {
defaultValue: false
}),
localeNameFlag: DS.attr('boolean', {
defaultValue: false
}),
localeLocationFlag: DS.attr('boolean', {
defaultValue: false
}),
allowSign: DS.attr('boolean', {
defaultValue: false
}),
Expand Down Expand Up @@ -226,10 +236,11 @@ FLOW.SurveyedLocale = DS.Model.extend({
keyId: DS.attr('number'),
latitude: DS.attr('number'),
longitude: DS.attr('number'),
primaryKey: 'keyId',
typeMark: DS.attr('string', {
defaultValue: 'WATER_POINT'
})
displayName: DS.attr('string'),
lastUpdateDateTime: DS.attr('number'),
surveyGroupId: DS.attr('number'),
identifier: DS.attr('string'),
primaryKey: 'keyId'
});

// Explicitly avoid to use belongTo and hasMany as
Expand Down
Loading

0 comments on commit 148ff4e

Please sign in to comment.