-
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: - Add relation support to form stage editor - Add relation input - Very rough relation output Test Plan: Add a relation field to a post type Edit a post, search for another post Select and save View the post and see a link to the related post Reviewers: lkamau, jasonmule, will Subscribers: jasonmule, will, rjmackay, lkamau Maniphest Tasks: T1442 Differential Revision: https://phabricator.ushahidi.com/D891
- Loading branch information
Showing
11 changed files
with
134 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
module.exports = [ | ||
'PostEndpoint', | ||
'_', | ||
function ( | ||
PostEndpoint, | ||
_ | ||
) { | ||
|
||
return { | ||
restrict: 'E', | ||
replace: true, | ||
scope: { | ||
id: '@', | ||
name: '@', | ||
model: '=', | ||
required: '=', | ||
attribute: '=' | ||
}, | ||
templateUrl: 'templates/posts/relation.html', | ||
link: function ($scope) { | ||
$scope.$watch(function () { | ||
return $scope.model; | ||
}, function (newValue, oldValue) { | ||
if (!$scope.selectedPost || $scope.selectedPost.id !== newValue) { | ||
$scope.selectedPost = PostEndpoint.get({ id: $scope.model }); | ||
} | ||
}); | ||
|
||
$scope.search = function (event) { | ||
event.preventDefault(); | ||
var query = { q : $scope.searchTerm }; | ||
|
||
if ($scope.attribute.config.input && $scope.attribute.config.input.form) { | ||
query.form = $scope.attribute.config.input.form.join(','); | ||
} | ||
|
||
PostEndpoint.query(query).$promise.then(function (response) { | ||
$scope.results = response.results; | ||
}); | ||
}; | ||
|
||
$scope.selectPost = function (post) { | ||
$scope.model = post.id; | ||
$scope.selectedPost = post; | ||
$scope.results = null; | ||
}; | ||
|
||
$scope.clearPost = function () { | ||
$scope.model = null | ||
$scope.selectedPost = null; | ||
}; | ||
} | ||
}; | ||
|
||
}]; |
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
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,12 @@ | ||
<form name="relation-search-form" class="input-relation"> | ||
<p ng-if="model">{{ selectedPost.title }} ({{ model }}) <button class="button-secondary icon-only alt trash" type="button" ng-click="clearPost()" translate></button></p> | ||
<div class="input-inline"> | ||
<input class="form-control" type="text" placeholder="Search.." ng-model="searchTerm"> | ||
<button class="btn btn-info" type="button" ng-click="search($event)" translate>nav.search</button> | ||
</div> | ||
<ul> | ||
<li ng-repeat="post in results"> | ||
<button type="button" class="button-secondary icon-only check" ng-click="selectPost(post)" translate></button> {{ post.id }} : {{ post.title }} | ||
</li> | ||
</ul> | ||
</form> |