Commit d249315f authored by Maria Kouiroukidou's avatar Maria Kouiroukidou

changes in PUT method

parent 25d371fc
......@@ -26,6 +26,13 @@ function [p.parentName.toUpperFirst()/]($scope, dataService, config, $filter, $l
$scope.model.[p.parentName/]s = ['['/]];
$scope.onLoad = onLoad;
$scope.editBoolean = false;
$scope.edit = function (editValue) {
$scope.editBoolean = editValue;
console.log($scope.editBoolean);
};
/**
* @ngdoc method
* @name onLoad
......@@ -100,9 +107,10 @@ function [p.parentName.toUpperFirst()/]($scope, dataService, config, $filter, $l
*This method is responsible for the PUT HTTP request.It sends an HTTP PUT request
* to update an existing instance of the current resource.
**/
$scope.update[p.parentName.toUpperFirst()/] = function(model) {
dataService.[if (anAnnotationStack.bHasAuthenticationAnnotation)][if (httpActivity.hasBothModeAuthentication(anAnnotationStack))]data[else]dataAuth[/if][else]data[/if](config.[p.parentName/]URL).update(model)
};
$scope.updateRecipe = function (model, url) {
console.log(model + url)
dataService.dataAuth(url).update(model)
};
[/if]
[/for]
[/for]
......@@ -149,12 +157,14 @@ function [p.parentName.toUpperFirst()/]($scope, dataService, config, $filter, $l
angular.forEach(data.linklist, function (link) {
if (link.linkType == 'Child' && link.linkVerb == 'GET') {
if (link.linkURI.substr(link.linkURI.lastIndexOf('/') + 1) == '[c.parentName/]') {
[for (aJavaResourceController : JavaResourceController | anAnnotationStack.hasCorePSM.hasJavaRController)]
[for (httpActivity : HTTPActivity | aJavaResourceController.JavaRControllerHasHTTPActivity)]
[if (httpActivity.ActivityHTTPVerb.toString() = 'POST' and aJavaResourceController.parentName = c.parentName and self.name=aJavaResourceController.firstOnly(httpActivity.ActivityHTTPVerb.toString()))]
dataService.[if (anAnnotationStack.bHasAuthenticationAnnotation)][if (httpActivity.hasBothModeAuthentication(anAnnotationStack))]data[else]dataAuth[/if][else]data[/if](link.linkURI).save(model)
[/if][/for][/for]
$location.path("/[p.parentName/]Detail")
[comment TODO /]
[for (aJavaResourceController : JavaResourceControllerManager | anAnnotationStack.hasCorePSM.hasJavaRCManager)]
[for (httpActivity : HTTPActivity | aJavaResourceController.JavaRCManagerHasHTTPActivity)]
[if (httpActivity.ActivityHTTPVerb.toString() = 'POST' and aJavaResourceController.parentName = c.parentName)]
dataService.[if (anAnnotationStack.bHasAuthenticationAnnotation)][if (httpActivity.hasBothModeAuthentication(anAnnotationStack))]data[else]dataAuth[/if][else]data[/if](link.linkURI).save(model, function (data) {
$location.path("/[p.parentName/]Detail")
})
[/if][/for][/for]
}
}
})
......@@ -414,7 +424,7 @@ function [p.parentName/]View($scope, $location, $window, $rootScope, $route, dat
[for (aJavaResourceController : JavaResourceController | anAnnotationStack.hasCorePSM.hasJavaRController)]
[for (httpActivity : HTTPActivity | aJavaResourceController.JavaRControllerHasHTTPActivity)]
[if (httpActivity.ActivityHTTPVerb.toString() = 'GET' and aJavaResourceController.parentName = p.parentName)]
$scope.model.detail = dataService.[if (anAnnotationStack.bHasAuthenticationAnnotation)][if (anAnnotationStack.getMainResources()->size() = 1)][if (anAnnotationStack.getMainResources()->at(1).parentName = anAnnotationStack.getAuthenticationPerformer().authenticationModelParentName)]data[else][if (httpActivity.hasBothModeAuthentication(anAnnotationStack))]dataAuth[else]data[/if](current[p.parentName.toUpperFirst()/])[/if][else]dataAuth(current[p.parentName.toUpperFirst()/].linkURI)[/if][else]data(current[p.parentName.toUpperFirst()/].linkURI)[/if].getall(function (callbackdata) {
$scope.model.detail = dataService.[if (anAnnotationStack.bHasAuthenticationAnnotation)][if (anAnnotationStack.getMainResources()->size() = 1)][if (anAnnotationStack.getMainResources()->at(1).parentName = anAnnotationStack.getAuthenticationPerformer().authenticationModelParentName)]data[else][if (httpActivity.hasBothModeAuthentication(anAnnotationStack))]dataAuth[else]data[/if]($rootScope.[p.parentName/]Url.linkURI)[/if][else]dataAuth($rootScope.[p.parentName/]Url.linkURI)[/if][else]data($rootScope.[p.parentName/]Url.linkURI)[/if].getall(function (callbackdata) {
[/if][/for][/for]
$scope.image = "data:image/jpg;base64," + $scope.model.detail.image
angular.forEach(callbackdata.linklist, function (link) {
......@@ -519,7 +529,7 @@ function [p.parentName/]View($scope, $location, $window, $rootScope, $route, dat
* It sends an HTTP PUT request and updates an instance of [c.parentName.toUpperFirst()/] resource
**/
$scope.update[c.parentName.toUpperFirst()/] = function(model, item) {
dataService.[if (anAnnotationStack.bHasAuthenticationAnnotation)]dataAuth[else]data[/if]($rootScope.[p.parentName/].linkURI).getall(function (data) {
dataService.[if (anAnnotationStack.bHasAuthenticationAnnotation)]dataAuth[else]data[/if]($rootScope.[p.parentName/]Url.linkURI).getall(function (data) {
angular.forEach(data.linklist, function (link) {
if (link.linkType == 'Child' && link.linkVerb == 'GET') {
if (link.linkURI.substr(link.linkURI.lastIndexOf('/') + 1) == '[c.parentName/]') {
......
......@@ -25,6 +25,7 @@
[/if]
[/if]
[/for]
<div ng-hide="editBoolean">
[for (c : PSMComponentProperty | p.hasRelatedJavaRModel.JavaRModelHasProperty)]
[if (c.type='String')]
[if not(c.name='image')]
......@@ -42,7 +43,31 @@
[/if]
[/if]
[/for]
</div>
<div ng-show="editBoolean">
[for (c : PSMComponentProperty | p.hasRelatedJavaRModel.JavaRModelHasProperty)]
[if (c.type='String')]
[if not(c.name='image')]
<div class="field">
<div class="ui large left icon input">
<input type="text" name="[c.name.toUpperFirst()/]" ng-model="model.[p.parentName/].[c.name/]">
</div>
</div>
[/if]
[elseif (c.type='int' or c.type = 'float')]
[if not(c.bIsPrimaryIdentifier)]
<div class="field">
<div class="ui large left icon input">
<input type="number" name="[c.name.toUpperFirst()/]" ng-model="model.[p.parentName/].[c.name/]">
</div>
</div>
[/if]
[/if]
[/for]
</div>
<br>
<div class="ui buttons">
<div [if (anAnnotationStack.bHasAuthenticationAnnotation)]ng-if="isLogedIn"[/if]>
[for (aJavaResourceController : JavaResourceController | anAnnotationStack.hasCorePSM.hasJavaRController)]
[for (httpActivity : HTTPActivity | aJavaResourceController.JavaRControllerHasHTTPActivity)]
[if (httpActivity.ActivityHTTPVerb.toString() = 'DELETE' and aJavaResourceController.parentName = p.parentName)]
......@@ -53,13 +78,20 @@
</div>
</div>
[elseif (httpActivity.ActivityHTTPVerb.toString() = 'PUT' and aJavaResourceController.parentName = p.parentName)]
<div class="ui vertical animated orange button" tabindex="0" [if (anAnnotationStack.bHasAuthenticationAnnotation)]ng-if="isLogedIn"[/if] ng-controller="[p.parentName.toUpperFirst()/]Controller" >
<div class="hidden content">Edit</div>
<div class="visible content">
<i class="edit icon"></i>
<div class="ui vertical animated orange button" ng-hide="editBoolean" tabindex="0" ng-click="edit(true)">
<div class="hidden content">Edit</div>
<div class="visible content">
<i class="edit icon"></i>
</div>
</div>
<div class="ui vertical animated positive button" ng-show="editBoolean" tabindex="0" ng-click="edit(false) ; update[p.parentName.toUpperFirst()/](model.[p.parentName/], [p.parentName/].linkURI)">
<div class="hidden content">Save</div>
<div class="visible content">
<i class="edit icon"></i>
</div>
</div>
</div>
[/if][/for][/for]
</div>
[if (anAnnotationStack.relatedResource(p.hasRelatedJavaRModel)->size()>0)]
<div class="ui animated button" tabindex="0" ng-controller="[p.parentName/]DetailController" ng-click="[p.parentName/]Detail([p.parentName/])">
<div class="visible content">Show More</div>
......
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