Subversion Repositories bacoAlunos

Rev

Rev 1726 | Rev 1728 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1726 Rev 1727
Line 90... Line 90...
90
 
90
 
91
    .tree-node-content {
91
    .tree-node-content {
92
        margin: 10px;
92
        margin: 10px;
93
    }
93
    }
94
 
94
 
-
 
95
    .lateMoved
-
 
96
    {
-
 
97
        border: 2px solid #65ebff !important;
95
 
98
    }
96
    /*Estilo adicionado por mim para os movidos*/
99
    /*Estilo adicionado por mim para os movidos*/
97
    .moved
100
    .moved
98
    {
101
    {
99
        border: 2px solid blue !important;
102
        border: 2px solid blue !important;
100
    }
103
    }
101
 
104
 
-
 
105
 
102
    .modified
106
    .modified
103
    {
107
    {
104
        border: 4px dashed orange !important;
108
        border: 4px dashed orange !important;
105
    }
109
    }
106
</style>
110
</style>
Line 131... Line 135...
131
GLOBAL_BacoAngularAppDependencies.push('treeAppPageContent');
135
GLOBAL_BacoAngularAppDependencies.push('treeAppPageContent');
132
 
136
 
133
<!-- estes codigos todos do remove e do toggle e etc's não mechi em nada limitei-me a copiar dos gajos-->
137
<!-- estes codigos todos do remove e do toggle e etc's não mechi em nada limitei-me a copiar dos gajos-->
134
treeAppPageContent.controller('treeAppPageContentController',  function ($scope) {
138
treeAppPageContent.controller('treeAppPageContentController',  function ($scope) {
135
 
139
 
-
 
140
            $scope.movedDocsIds = [];
-
 
141
            $scope.lateMovedDocsIds = [];
-
 
142
 
136
            $scope.data = ${collectionsJson};
143
            $scope.data = ${collectionsJson};
137
 
144
 
138
            $scope.onlyVisibles = false;
145
            $scope.onlyVisibles = false;
139
 
146
 
140
            /*
147
            /*
Line 185... Line 192...
185
                if(node.childs == null)
192
                if(node.childs == null)
186
                    return false;
193
                    return false;
187
                return node.childs.length == 0;
194
                return node.childs.length == 0;
188
            }
195
            }
189
 
196
 
190
            $scope.removeCheckedDocuments = function(collection)
197
            $scope.removeCollection = function (collection,parent)
191
            {
198
            {
-
 
199
 
-
 
200
 
-
 
201
                widgetSimpleCallWithActionParameters(
192
                angular.forEach(collection.childs, function(collection, key) {
202
                        "<%=request.getContextPath()%>/user/repositoryDoc.do",
193
                    $scope.removeCheckedDocuments(collection);
203
                        "deleteCollection",
194
                });
204
                        {
195
                angular.forEach(collection.documents, function(document, key) {
205
                            "collectionId" : collection.id
-
 
206
                        },
-
 
207
                        "#treeAppPageContent",
-
 
208
                        function()
-
 
209
                        {
-
 
210
                            if(parent)
-
 
211
                            {
196
                    var index = $scope.checkedDocuments.indexOf(document);
212
                                var index = parent.childs.indexOf(collection);
197
                    $scope.checkedDocuments.splice(index, 1);
213
                                parent.childs.splice(index, 1);
-
 
214
                            }
-
 
215
                            else
-
 
216
                            {
-
 
217
                                scope.remove();
-
 
218
                            }
-
 
219
                            $scope.$apply();
-
 
220
                        }
198
                });
221
                );
-
 
222
 
199
            }
223
            };
200
 
224
 
201
            $scope.changeDocumentCollection = function(collection)
225
            $scope.changeDocumentCollection = function(collection)
202
            {
226
            {
-
 
227
                var documentIdsToMove = [];
203
                angular.forEach($scope.checkedDocuments, function(document, key)
228
                angular.forEach($scope.checkedDocuments, function(documentContainer, key)
204
                {
229
                {
205
                    //var index = $scope.checkedDocuments.indexOf(document);
230
                    documentIdsToMove.push(documentContainer.document.id);
206
                    //$scope.checkedDocuments.splice(index, 1);
-
 
207
 
-
 
208
                    collection.push(document);
-
 
209
                });
231
                });
210
                widgetSimpleCallWithActionParameters(
232
                widgetSimpleCallWithActionParameters(
211
                        "<%=request.getContextPath()%>/user/repositoryDoc.do",
233
                        "<%=request.getContextPath()%>/user/repositoryDoc.do",
212
                        "changeDocumentCollection",
234
                        "changeDocumentCollection",
213
                        {
235
                        {
214
                            "id" : collection.id,
236
                            "newCollectionId" : collection.id,
215
                            "documents" : JSON.stringify($scope.checkedDocuments)
237
                            "documentIds" : JSON.stringify(documentIdsToMove)
216
                        },
238
                        },
217
                        "#treeAppPageContent",
239
                        "#treeAppPageContent",
218
                        function()
240
                        function()
219
                        {
241
                        {
-
 
242
                            //Adicionar aos Movidos
-
 
243
                            $scope.movedDocsIds = [];
220
                            angular.forEach($scope.checkedDocuments, function(document, key)
244
                            angular.forEach($scope.checkedDocuments, function(documentContainer, key)
221
                            {
245
                            {
222
                                //var index = $scope.checkedDocuments.indexOf(document);
246
                                console.log("pushing doc " + documentContainer.document.id);
223
                                //$scope.checkedDocuments.splice(index, 1);
247
                                $scope.movedDocsIds.push(documentContainer.document.id);
224
 
-
 
225
                                collection.push(document);
248
                                $scope.lateMovedDocsIds.push(documentContainer.document.id);
226
                            });
249
                            });
-
 
250
                            if(collection.open && collection.open==true)
-
 
251
                            {
-
 
252
                                //Adicionar A colecção Nova se estiver aberta
-
 
253
                                angular.forEach($scope.checkedDocuments, function(documentContainer, key)
-
 
254
                                {
-
 
255
                                    //ERRO QUANDO SE PUDHAM DOIS
-
 
256
                                    collection.documents.push(documentContainer.document);
-
 
257
                                    delete documentContainer.document.checked;
-
 
258
                                });
-
 
259
                            }
-
 
260
                            else
-
 
261
                            {
-
 
262
                                //Abrir se não estiver
-
 
263
                                $scope.openItem(collection);
-
 
264
                            }
-
 
265
                            //Remover da colecção original
-
 
266
                            angular.forEach($scope.checkedDocuments, function(documentContainer, key)
-
 
267
                            {
-
 
268
                                var index = documentContainer.collection.documents.indexOf(documentContainer.document);
-
 
269
                                documentContainer.collection.documents.splice(index, 1);
227
 
270
 
-
 
271
                            });
-
 
272
                            $scope.checkedDocuments = [];
228
                            $scope.$apply();
273
                            $scope.$apply();
229
                        },
274
                        },
230
                        function()
275
                        function()
231
                        {
276
                        {
232
                            alert("A operação falhou, verifique os erros");
277
                            alert("A operação falhou, verifique os erros");
233
                        }
278
                        }
234
                );
279
                );
235
            }
280
            }
-
 
281
            $scope.documentMoved = function(document)
-
 
282
            {
-
 
283
                var returnValue = false;
-
 
284
                angular.forEach($scope.movedDocsIds, function(docId, key)
-
 
285
                {
-
 
286
                    if(document.id == docId)
-
 
287
                        returnValue = true;
-
 
288
                });
-
 
289
                return returnValue;
-
 
290
            }
-
 
291
            $scope.lateDocumentMoved = function(document)
-
 
292
            {
-
 
293
                var returnValue = false;
-
 
294
                angular.forEach($scope.lateMovedDocsIds, function(docId, key)
-
 
295
                {
-
 
296
                    if(document.id == docId)
-
 
297
                        returnValue = true;
-
 
298
                });
-
 
299
                return returnValue;
-
 
300
            }
-
 
301
 
-
 
302
            $scope.removeCheckedDocuments = function(collection)
-
 
303
            {
-
 
304
                angular.forEach(collection.childs, function(collection, key) {
-
 
305
                    $scope.removeCheckedDocuments(collection);
-
 
306
                });
-
 
307
                angular.forEach(collection.documents, function(document, key)
-
 
308
                {
-
 
309
                    angular.forEach($scope.checkedDocuments, function(documentContainer, key)
-
 
310
                    {
-
 
311
                        if(documentContainer.document == document)
-
 
312
                        {
-
 
313
                            var index = $scope.checkedDocuments.indexOf(documentContainer);
-
 
314
                            $scope.checkedDocuments.splice(index, 1);
-
 
315
                        }
-
 
316
                    });
-
 
317
                });
-
 
318
            }
236
 
319
 
237
 
320
 
238
            $scope.openItem = function(item)
321
            $scope.openItem = function(item)
239
            {
322
            {
240
                //apenas deixa abrir neste caso
323
                //apenas deixa abrir neste caso
Line 293... Line 376...
293
                    item.open=true;
376
                    item.open=true;
294
                    collapseElement.collapse("show");
377
                    collapseElement.collapse("show");
295
                }
378
                }
296
            }
379
            }
297
            $scope.checkedDocuments = [];
380
            $scope.checkedDocuments = [];
298
            $scope.checkDocument = function(document)
381
            $scope.checkDocument = function(document,collection)
299
            {
382
            {
300
                //document = scope.$childNodesScope.$modelValue;
-
 
301
                if(document.checked)
383
                if(document.checked)
302
                {
384
                {
-
 
385
                    var docContainer =
-
 
386
                    {
-
 
387
                        "document" : document,
-
 
388
                        "collection" : collection
-
 
389
                    }
303
                    $scope.checkedDocuments.push(document);
390
                    $scope.checkedDocuments.push(docContainer);
304
                }
391
                }
305
                else
392
                else
306
                {
393
                {
-
 
394
                    angular.forEach($scope.checkedDocuments, function(documentContainer, key)
-
 
395
                    {
-
 
396
                        if(documentContainer.document == document)
-
 
397
                        {
307
                    var index = $scope.checkedDocuments.indexOf(document);
398
                            var index = $scope.checkedDocuments.indexOf(documentContainer);
308
                    $scope.checkedDocuments.splice(index, 1);
399
                            $scope.checkedDocuments.splice(index, 1);
-
 
400
                        }
-
 
401
                    });
309
                }
402
                }
310
            }
403
            }
311
 
404
 
312
 
405
 
-
 
406
 
-
 
407
 
313
            $scope.hideNode = function(node)
408
            $scope.hideNode = function(node)
314
            {
409
            {
315
                if(!node.visible && $scope.onlyVisibles)
410
                if(!node.visible && $scope.onlyVisibles)
316
                    return true;
411
                    return true;
317
                return false;
412
                return false;
Line 337... Line 432...
337
</script>
432
</script>
338
 
433
 
339
<!--TEMPLATE RECURSIVO-->
434
<!--TEMPLATE RECURSIVO-->
340
<script type="text/ng-template" id="childs_renderer.html">
435
<script type="text/ng-template" id="childs_renderer.html">
341
    <!--Para nao deixar fazer drag-->
436
    <!--Para nao deixar fazer drag-->
342
    <div data-nodrag class="tree-node tree-node-content clearfix" ng-class="{modified: node.modified, nodrop: node.nodrop, nodrag: node.nodrag, moved: node.moved, bacoInvisible: !node.visible, hidden: hideNode(node)}">
437
    <div ng-init="collection = node" data-nodrag class="tree-node tree-node-content clearfix" ng-class="{modified: node.modified, nodrop: node.nodrop, nodrag: node.nodrag, bacoInvisible: !node.visible, hidden: hideNode(node)}">
343
 
-
 
344
 
-
 
345
 
-
 
346
            <button ng-click="changeDocumentCollection(node)" data-toggle="tooltip" title="Mover documentos para aqui" class="btn btn-xs btn-warning" ng-show="checkedDocuments.length"><span class="glyphicon glyphicon-arrow-right"></span></button>
-
 
347
 
438
 
348
            <a class="btn btn-xs" ng-class="{
439
            <a class="btn btn-xs" ng-class="{
349
                                            'btn-default': !node.open,
440
                                            'btn-default': !node.open,
350
                                            'btn-success': node.open,
441
                                            'btn-success': node.open,
351
                                          }"
442
                                          }"
Line 372... Line 463...
372
                <span class="glyphicon glyphicon-ban-circle"/>
463
                <span class="glyphicon glyphicon-ban-circle"/>
373
            </label>
464
            </label>
374
 
465
 
375
            {{node.name}}
466
            {{node.name}}
376
 
467
 
-
 
468
            <button ng-click="changeDocumentCollection(node)" data-toggle="tooltip" title="Mover documentos para aqui" class="btn btn-xs btn-warning" ng-show="checkedDocuments.length"><span class="glyphicon glyphicon-arrow-left"></span></button>
-
 
469
 
-
 
470
            <button ng-click="removeCollection(node,parent)" data-toggle="tooltip" title="Remover Colecção" class="btn btn-xs btn-danger pull-right"><span class="glyphicon glyphicon-remove"></span></button>
377
 
471
 
378
    </div>
472
    </div>
379
 
473
 
380
 
474
 
381
    <ol data-nodrag ui-tree-nodes="" data-nodrop-enabled="true" ng-model="node" ng-class="{hidden: collapsed }">
475
    <ol data-nodrag ui-tree-nodes="" data-nodrop-enabled="true" ng-model="node" ng-class="{hidden: collapsed }">
382
        <li ng-repeat="node in node.childs" ui-tree-node ng-include="'childs_renderer.html'">
476
        <li ng-repeat="node in node.childs" ui-tree-node ng-include="'childs_renderer.html'" ng-init="parent = collection">
383
        </li>
477
        </li>
384
        <li ng-repeat="node in node.documents" ui-tree-node ng-include="'documents_renderer.html'">
478
        <li ng-repeat="node in node.documents" ui-tree-node ng-include="'documents_renderer.html'">
385
        </li>
479
        </li>
386
    </ol>
480
    </ol>
387
 
481
 
Line 389... Line 483...
389
</script>
483
</script>
390
 
484
 
391
<!--TEMPLATE RECURSIVO-->
485
<!--TEMPLATE RECURSIVO-->
392
<script type="text/ng-template" id="documents_renderer.html">
486
<script type="text/ng-template" id="documents_renderer.html">
393
    <!--Para nao deixar fazer drag-->
487
    <!--Para nao deixar fazer drag-->
394
    <div data-nodrag class="tree-node tree-node-document tree-node-content clearfix" ng-class="{modified: node.modified, nodrop: node.nodrop, nodrag: node.nodrag, moved: node.moved, bacoInvisible: !node.visible, hidden: hideNode(node)}">
488
    <div data-nodrag class="tree-node tree-node-document tree-node-content clearfix" ng-class="{modified: node.modified, nodrop: node.nodrop, nodrag: node.nodrag, moved: documentMoved(node),lateMoved: lateDocumentMoved(node), bacoInvisible: !node.visible, hidden: hideNode(node)}">
395
 
489
 
-
 
490
        <!--a var collection vem do template da colecção pai onde se fez ng-init="collection = node"-->
396
        <input type="checkbox" ng-click="checkDocument(node)" ng-model="node.checked" style="font-size: 1.4em; margin-right: 10px">
491
        <input type="checkbox" ng-click="checkDocument(node,collection)" ng-model="node.checked" style="font-size: 1.4em; margin-right: 10px">
397
        <a class="btn btn-xs" ng-class="{
492
        <a class="btn btn-xs" ng-class="{
398
                                        'btn-default': !node.open,
493
                                        'btn-default': !node.open,
399
                                        'btn-success': node.open,
494
                                        'btn-success': node.open,
400
                                      }"
495
                                      }"
401
           data-nodrag data-toggle="collapse" ng-click="openDocumentsItem(node)">
496
           data-nodrag data-toggle="collapse" ng-click="openDocumentsItem(node)">
402
                        <span
497
                        <span
403
                                class="glyphicon"
498
                                class="glyphicon"
404
                                ng-class="{
499
                                ng-class="{
405
 
500
 
406
                                        'glyphicon-chevron-right': !node.open,
501
                                        'glyphicon-zoom-in': !node.open,
407
                                        'glyphicon-chevron-down': node.open
502
                                        'glyphicon-zoom-out': node.open
408
 
503
 
409
                                      }">
504
                                      }">
410
                        </span>
505
                        </span>
411
        </a>
506
        </a>
412
 
507
 
Line 416... Line 511...
416
 
511
 
417
 
512
 
418
 
513
 
419
 
514
 
420
 
515
 
421
        <span class="glyphicon glyphicon-file"></span>  {{node.title}}
516
        <span class="glyphicon glyphicon-file"></span>  {{node.title}} {{node.id}}
422
 
517
 
423
        <baco:hasRole role="admin,all,repositoryDocs">
518
        <baco:hasRole role="admin,all,repositoryDocs">
424
            <a target="_blank" class="pull-right btn btn-warning btn-xs" href="<%=request.getContextPath()%>/user/repositoryEditDocument.do?repositoryDocumentId={{node.id}}">
519
            <a target="_blank" class="pull-right btn btn-warning btn-xs" href="<%=request.getContextPath()%>/user/repositoryEditDocument.do?repositoryDocumentId={{node.id}}">
425
                <span class="glyphicon glyphicon-pencil"></span>
520
                <span class="glyphicon glyphicon-pencil"></span>
426
            </a>
521
            </a>