Commit 764d8593 authored by Evren Kutar's avatar Evren Kutar

add listnode item to table and edit correct item

parent 2072228e
<div class="tablescroll">
<table class="table table-bordered" style="background-color:#fff;">
<thead>
<tr>
<tr ng-if="node.schema.formType=='Node'">
<!--<th colspan="2">-->
<!--<label>-->
<!--<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">-->
<!--Hepsini Seç-->
<!--</label>-->
<!--</th>-->
<th ng-repeat="(key,value) in node.model">{{ key }}</th>
<th>İşlem</th>
</tr>
<tr ng-if="node.schema.formType=='ListNode'">
<th colspan="2">
<label>
<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">
Hepsini Seç
</label>
</th>
<th ng-repeat="(key,value) in node.model">{{ key }}</th>
<th>action</th>
<th ng-repeat="(key,value) in node.model[0]">{{ key }}</th>
<th>İşlem</th>
</tr>
</thead>
<tbody ng-class="{hidden: node.lengthModels < 1}">
<tr ng-if="node.schema.formType=='Node'">
<td width="60">
<label>
<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">
</label>
</td>
<th scope="row" style="text-align:center">1</th>
<!--<td width="60">-->
<!--<label>-->
<!--<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">-->
<!--</label>-->
<!--</td>-->
<!--<th scope="row" style="text-align:center">1</th>-->
<td ng-repeat="value in node.model">{{ value }}</td>
<td>
<button modal-for-nodes="{{node.schema.model_name}},{{node.schema.formType}},edit">Edit</button><br>
<button>Show</button>
<button>Delete</button>
<button modal-for-nodes="{{node.schema.model_name}},{{node.schema.formType}},edit">Düzenle</button><br>
<button>Sil</button>
</td>
</tr>
......@@ -35,12 +44,11 @@
<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">
</label>
</td>
<th scope="row" style="text-align:center">1</th>
<td ng-repeat="value in listnodemodel">{{ value }}</td>
<th scope="row" style="text-align:center">{{$index+1}}</th>
<td ng-repeat="(k, v) in listnodemodel">{{ v }}</td>
<td>
<button modal-for-nodes="{{node.schema.model_name}},{{node.schema.formType}},edit">Edit</button><br>
<button>Show</button>
<button>Delete</button>
<button modal-for-nodes="{{node.schema.model_name}},{{node.schema.formType}},edit,{{$index}}">Düzenle</button><br>
<button>Sil</button>
</td>
</tr>
......
......@@ -126,7 +126,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
};
if (scope.model[v] == null) {
scope[k.type][v].model = k.type == 'Node' ? [] : {};
scope[k.type][v].model = k.type == 'Node' ? {} : [];
} else {
scope[k.type][v].model = scope.model[v];
}
......@@ -286,34 +286,38 @@ form_generator.directive('modalForNodes', function ($modal) {
resolve: {
items: function () {
var attribs = attributes['modalForNodes'].split(',');
debugger;
// get node from parent scope catch with attribute
var node = angular.copy(scope.$parent[attribs[1]][attribs[0]]);
if(attribs[2] == 'add'){
node.model = {};
}
if(attribs[3]){
// if listnode catch edit object with index
node.model=node.model[attribs[3]];
}
// tell result.then function which item to edit
node.edit = attribs[3];
return node;
}
}
});
modalInstance.result.then(function (childmodel, key) {
// subfix will be removed
//var subfix = scope.schema.title.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
if (childmodel.schema.formType == 'Node') {
//scope.$parent.model[childmodel.schema.model_name] = childmodel.model;
scope.$parent[childmodel.schema.formType][childmodel.schema.model_name].model = childmodel.model;
}
if (childmodel.schema.formType == 'ListNode') {
if (scope.$parent.model[childmodel.schema.model_name] == null) {
scope.$parent.model[childmodel.schema.model_name] = [];
if(childmodel.edit){
scope.$parent[childmodel.schema.formType][childmodel.schema.model_name].model[childmodel.edit] = childmodel.model;
} else {
scope.$parent[childmodel.schema.formType][childmodel.schema.model_name].model.push(childmodel.model);
}
//scope.$parent.model[childmodel.schema.model_name].push(childmodel.model);
scope.$parent[childmodel.schema.formType][childmodel.schema.model_name].model.push(childmodel.model);
}
scope.$parent[childmodel.schema.formType][childmodel.schema.model_name].lengthModels += 1;
......
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