-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: What works: - View a list of all post types - add/edit/delete post types - Add/edit/delete form attributes - Add/edit/delete form stages - Attribute re-ordering - Stage re-ordering Still missing - Visible To/Editable By permissions - missing on the backend - Field instructions - also missing on the backend Test Plan: Edit a form, add stages and fields save and check they're reflected elsewhere. Same with a new form. Reviewers: aMoniker, vladimir, lkamau Subscribers: rjmackay, vladimir, lkamau, aMoniker Maniphest Tasks: T1139 Differential Revision: https://phabricator.ushahidi.com/D777
- Loading branch information
Showing
26 changed files
with
988 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module.exports = [ | ||
'$resource', | ||
'Util', | ||
function ( | ||
$resource, | ||
Util | ||
) { | ||
|
||
var FormStageEndpoint = $resource(Util.apiUrl('/forms/:formId/stages/:id'), { | ||
formId: '@formId', | ||
id: '@id', | ||
order: 'asc', | ||
orderby: 'priority' | ||
}, { | ||
query: { | ||
method: 'GET', | ||
isArray: true, | ||
transformResponse: function (data /*, header*/) { | ||
return Util.transformResponse(data).results; | ||
} | ||
}, | ||
update: { | ||
method: 'PUT' | ||
}, | ||
delete: { | ||
method: 'DELETE' | ||
} | ||
}); | ||
|
||
return FormStageEndpoint; | ||
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,41 @@ | ||
module.exports = [ | ||
'$scope', | ||
'$translate', | ||
'$location', | ||
'FormEndpoint', | ||
function ( | ||
$scope, | ||
$translate | ||
$translate, | ||
$location, | ||
FormEndpoint | ||
) { | ||
|
||
$translate('tool.manage_forms').then(function (title) { | ||
$scope.title = title; | ||
$scope.$emit('setPageTitle', title); | ||
}); | ||
$translate('nav.posts_and_entities').then(function (title) { | ||
$scope.title = title; | ||
$scope.$emit('setPageTitle', title); | ||
}); | ||
|
||
// Get all the forms for display | ||
FormEndpoint.get().$promise.then(function (response) { | ||
$scope.forms = response.results; | ||
}); | ||
|
||
// Manage new form settings | ||
$scope.isNewFormOpen = false; | ||
$scope.openNewForm = function () { | ||
$scope.newForm = {}; | ||
$scope.isNewFormOpen = !$scope.isNewFormOpen; | ||
}; | ||
$scope.saveNewForm = function (form) { | ||
FormEndpoint | ||
.save(form) | ||
.$promise | ||
.then(function (form) { | ||
$scope.isNewFormOpen = false; | ||
$scope.newForm = {}; | ||
$location.url('/settings/forms/' + form.id); | ||
}); | ||
}; | ||
// End new form | ||
|
||
}]; |
35 changes: 35 additions & 0 deletions
35
app/setting/controllers/setting-forms-create-controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module.exports = [ | ||
'$scope', | ||
'$q', | ||
'FormEndpoint', | ||
'FormAttributeEndpoint', | ||
'_', | ||
function ( | ||
$scope, | ||
$q, | ||
FormEndpoint, | ||
FormAttributeEndpoint, | ||
_ | ||
) { | ||
|
||
// Get all the forms for display | ||
FormEndpoint.get().$promise.then(function (response) { | ||
var forms = response.results; | ||
|
||
// Get all form attributes for each form | ||
var attribute_promises = []; | ||
_.each(forms, function (form) { | ||
attribute_promises.push( | ||
FormAttributeEndpoint.query({ formId: form.id }).$promise | ||
); | ||
}); | ||
|
||
$q.all(attribute_promises).then(function (data) { | ||
_.each(data, function (datum, idx) { | ||
forms[idx].attributes = [].concat(data[idx]); | ||
}); | ||
$scope.forms = forms; | ||
}); | ||
}); | ||
|
||
}]; |
11 changes: 11 additions & 0 deletions
11
app/setting/controllers/setting-forms-create-template-controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = [ | ||
'$scope', | ||
'$routeParams', | ||
function ( | ||
$scope, | ||
$routeParams | ||
) { | ||
|
||
$scope.form_template = $routeParams.id; | ||
|
||
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module.exports = [ | ||
'$scope', | ||
'$routeParams', | ||
'$q', | ||
'FormEndpoint', | ||
'FormStageEndpoint', | ||
function ( | ||
$scope, | ||
$routeParams, | ||
$q, | ||
FormEndpoint, | ||
FormStageEndpoint | ||
) { | ||
|
||
$scope.formId = $routeParams.id; | ||
|
||
// If we're editing an existing form, | ||
// load the form info and all the fields. | ||
$q.all([ | ||
FormEndpoint.get({ id: $scope.formId }).$promise, | ||
FormStageEndpoint.query({ formId: $scope.formId }).$promise | ||
]).then(function (results) { | ||
var form = results[0]; | ||
form.stages = results[1]; | ||
$scope.form = form; | ||
}); | ||
|
||
}]; |
28 changes: 28 additions & 0 deletions
28
app/setting/controllers/setting-forms-edit-stage-controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module.exports = [ | ||
'$scope', | ||
'$routeParams', | ||
'$q', | ||
'FormEndpoint', | ||
'FormStageEndpoint', | ||
function ( | ||
$scope, | ||
$routeParams, | ||
$q, | ||
FormEndpoint, | ||
FormStageEndpoint | ||
) { | ||
|
||
$scope.formId = $routeParams.formId; | ||
$scope.stageId = $routeParams.id; | ||
|
||
// If we're editing an existing form, | ||
// load the form info and all the fields. | ||
$q.all([ | ||
FormEndpoint.get({ id: $scope.formId }).$promise, | ||
FormStageEndpoint.get({ formId: $scope.formId, id: $scope.stageId }).$promise | ||
]).then(function (results) { | ||
$scope.form = results[0]; | ||
$scope.stage = results[1]; | ||
}); | ||
|
||
}]; |
Oops, something went wrong.