folder.html 18.5 KB
Newer Older
1
2
<div class="col-xs-12" id="folderPanel" data-translate-catalog="recordsManagement/message">
    <div id="welcomMessage">
3
4
        <i class="fa fa-arrow-left col-xs-1"/>
        <h2 class="col-xs-11"> Select an organization unit or a folder in the tree to access an archive or to create a new one.</h2>
5
6
    </div>
    <div class="row folderContents hide">
Prosper De Laure's avatar
Prosper De Laure committed
7
        <ol class="breadcrumb" id="folderBreadcrumb">
8
            <li><a href="#"> </a></li>
Prosper De Laure's avatar
Prosper De Laure committed
9
        </ol>
10
    </div>
11
    <div id="folderContents" class="folderContents hide">
12
        <div id="fodlerToolbar" class="row">
Prosper De Laure's avatar
Prosper De Laure committed
13
14
15
            <h4 class="pull-left col-md-4 lockedFolder hide">
                <i class="text-danger fa fa-lock" style="font-size: 30px"/>
            </h4>
16
            <div class="col-xs-10">
17
            <?hinclude recordsManagement/archive/fulltextSearchForm.html ?>
18
            </div>
19
            <div class="col-xs-2">
20
21
22
                <button type="button" class="btn btn-warning pull-right hide" id="folderToolbarCloseSearch" title="Close search">
                    <span class="fa fa-close">&nbsp;</span> Close search
                </button>
23
24
25
26
27
28
29
                <div id="folderToolbarBtn" class="dropdown btn-group">
                    <button type="button" class="btn btn-success dropdown-toggle pull-right [?merge depositPrivilege.not().then('disabled', '') ?]" id="folderToolbarImport" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" title="New archive" disabled>
                        <span class="fa fa-plus">&nbsp;</span> New archive
                    </button>
                    <ul class="dropdown-menu pull-right">
                    </ul>
                </div>
Prosper De Laure's avatar
Prosper De Laure committed
30
            </div>
Prosper De Laure's avatar
Prosper De Laure committed
31
        </div>
Prosper De Laure's avatar
Prosper De Laure committed
32
33
34
        <div id="folderContentList">
            <div class="row hide">
            </div>
Prosper De Laure's avatar
Prosper De Laure committed
35
36
        </div>
    </div>
37
38
39
</div>

<div id="listTemplate" class="hide">
Prosper De Laure's avatar
Prosper De Laure committed
40
    <div class="archive row" style="border-bottom: 1px solid #DDD">
41
        <div class="archiveInfo pull-left">
42
            <h5>
43
                <i class="archiveContentButton fa fa-caret-right">&nbsp;</i>
44
                <i class="fileplanLevel">&nbsp;</i>
45
                <span class="archiveName"></span>
46
                <span class="status hidden"></span>
47
                <br/>
Jerome Boucher's avatar
Jerome Boucher committed
48
49
50
                &nbsp;
                <small/>
                <small/>
51
                <small><i/></small>
52
53
54
55
                <small class="folderInfo">
                    <br/>
                    <span></span>
                </small>
56
            </h5>
Cyril Vazquez's avatar
Cyril Vazquez committed
57
        </div>
58
        <?merge depositPrivilege.bool() ?>
59
        <div class="dropdown pull-right addChildrenArchive addingNew hide">
60
61
62
63
            <button class="btn btn-xs btn-default" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <span class="fa fa-plus"></span>
            </button>
            <ul class="dropdown-menu">
64
65
66
67
            </ul>
        </div>
        <div class="archiveContent hide">
            <ul class="tree-l">
68
69
            </ul>
        </div>
Cyril Vazquez's avatar
Cyril Vazquez committed
70
    </div>
Alexis Ragot's avatar
Alexis Ragot committed
71
</div>
72
73

<div class="hide">
74
    <span id="resultsOfSearch">Results of search in</span>
75
    <span id="archives_text">archives</span>
Prosper De Laure's avatar
Prosper De Laure committed
76
    <span id="archive_text">archive</span>
77
78
    <span id="foundArchives_text">archives found</span>
    <span id="foundArchive_text">archive found</span>
Prosper De Laure's avatar
Prosper De Laure committed
79
    <span id="rows_text">rows</span>
Prosper De Laure's avatar
Prosper De Laure committed
80
81
82
    <span id="emptyFolder_text">Empty folder</span>
    <span id="archiveName_text">Name</span>
    <span id="depositDate_text">Deposit date</span>
Prosper De Laure's avatar
Prosper De Laure committed
83
84
85
86
    <span id="first_text">First</span>
    <span id="previous_text">Previous</span>
    <span id="next_text">Next</span>
    <span id="last_text">Last</span>
87
    <span id="withoutProfile_text">Without profile</span>
Jerome Boucher's avatar
Jerome Boucher committed
88

89
</div>
90
91
92
93
94
95
96
<style type="text/css">
    #welcomMessage i{
        font-size: 40px;
        padding-top: 15px;
    }
    #welcomMessage {
        margin-top: 20%;
Prosper De Laure's avatar
Prosper De Laure committed
97
98
99
    }
</style>

Alexis Ragot's avatar
Alexis Ragot committed
100
<script type="text/javascript">
Shiva SIVANESARAJAH's avatar
Shiva SIVANESARAJAH committed
101
    trigger("setSearchBarClass.recordsManagement", ['col-md-10']);
102

103
104
    $("#folderToolbarCloseSearch").on('click', function(e) {
        trigger('folderView.recordsManagement');
105
        FilePlan.load($("#filePlanTree").find('.node-warning').closest('li'));
106
    });
107

108
    $("#folderToolbarBtn").onEvent("showSearchResult.recordsManagement", function (e) {
109
110
111
112
113
114
115
116
117
118
119
        ToolbarButtons.initSearchView();
    });

    $("#folderToolbarBtn").onEvent("folderView.recordsManagement", function (e) {
        ToolbarButtons.initfolderView();
    });

    ToolbarButtons = {
        initSearchView: function() {
            $("#folderToolbarCloseSearch").removeClass("hide");
            $("#folderToolbarImport").addClass("hide");
120
            $('#folderBreadcrumb').html($('#resultsOfSearch').text() + ' : ' + $("#filePlanTree").find('.node-warning').closest('li').data('path').replace(/\//g, ' > '));
121
122
123
124
        },
        initfolderView: function() {
            $("#folderToolbarCloseSearch").addClass("hide");
            $("#folderToolbarImport").removeClass("hide");
125
126
127
            $("input[name=searchForm_inputSearch]").val("");
            $("[name=originatingDateMin]").datepicker('setDate', null);
            $("[name=originatingDateMax]").datepicker('setDate', null);
128
129
130
        }
    }

Prosper De Laure's avatar
Prosper De Laure committed
131
132
133
    FolderBreadcrumb = {
        breadcrumb    : $('#folderBreadcrumb'),
        load: function(path) {
134
            var height = 0;
Prosper De Laure's avatar
Prosper De Laure committed
135
136
            this.breadcrumb.html('');

137
138
139
140
141
142
            for(i=0; i<path.length; i++) {
                this.buildLink(path[i], true).prependTo(this.breadcrumb);

                if (height == 0) {
                    height = this.breadcrumb.height();
                }
Prosper De Laure's avatar
Prosper De Laure committed
143
            }
Prosper De Laure's avatar
Prosper De Laure committed
144
145

            this.breadcrumb.find('li:last>a').data('orgregnumber', '');
146
147
148
149
150
151
152
153
            if (this.breadcrumb.height() > height) {
                var dots = $('<a/>').attr('href', '#')
                                    .attr('type', 'button')
                                    .attr('aria-haspopup', 'true')
                                    .attr('aria-expanded', 'false')
                                    .attr('data-toggle', 'dropdown')
                                    .text('...');
                var ul = $('<ul/>').addClass('dropdown-menu');
Jerome Boucher's avatar
Jerome Boucher committed
154

155
156
157
                var dropdown = $('<li/>').addClass('dropdown').append(dots).append(ul);

                this.breadcrumb.prepend(dropdown);
Jerome Boucher's avatar
Jerome Boucher committed
158

159
160
161
162
163
164
165
166
167
168
                i=path.length-1;

                while(this.breadcrumb.height() > height && i>=0) {
                    this.buildLink(path[i]).appendTo(ul);
                    this.breadcrumb.find('>li:nth-child(2)').remove();
                    i--;
                }

            }

Prosper De Laure's avatar
Prosper De Laure committed
169
170
        },

171
        buildLink: function(e, truncate) {
172
173
            var text = e[0];
            return $('<li/>').append($('<a/>').attr('href', '#').text(text).data('orgregnumber', e[1]));
174
        },
Prosper De Laure's avatar
Prosper De Laure committed
175

176
        selectFolder: function(e) {
Prosper De Laure's avatar
Prosper De Laure committed
177
178
            var orgRegNumber = e.data('orgregnumber');
            if (orgRegNumber) {
Prosper De Laure's avatar
Prosper De Laure committed
179
                trigger('loadFolder.filePlan', [orgRegNumber]);
Prosper De Laure's avatar
Prosper De Laure committed
180
            }
181
182
183
184
185
186
187
188
        },

        lockNavigation : function() {
            this.breadcrumb.find('a').prop('disabled', true);
        },

        unlockNavigation : function() {
            this.breadcrumb.find('a').prop('disabled', false);
Prosper De Laure's avatar
Prosper De Laure committed
189
        }
190
    };
191
    ArchiveFolderList = {
Cyril Vazquez's avatar
Cyril Vazquez committed
192
        rowTemplate    : $('#listTemplate .archive').clone(),
Prosper De Laure's avatar
Prosper De Laure committed
193
194
195
        folderContents : $('#folderContentList'),
        folderPanel    : $('#folderPanel'),
        orgRegNumber   : null,
196
197
198
        folderId       : null,
        pathList       : [],
        showArchivePath: false,
199

200
        getfolderContents: function(orgRegNumber, folderId, archivalProfiles, locked, acceptArchivesWithoutProfiles, pathList) {
Prosper De Laure's avatar
Prosper De Laure committed
201
202
            this.orgRegNumber = orgRegNumber;
            this.folderId = folderId;
203
            this.pathList = pathList;
Prosper De Laure's avatar
Prosper De Laure committed
204
            this.show();
205
            $('#welcomMessage').addClass('hide')
206
            var url = "/folder?originatorOrgRegNumber="+orgRegNumber;
207
            if (folderId) {
208
                url = url + "&filePlanPosition="+folderId;
209
            }
210
            if (locked) {
211
                this.folderPanel.find('.lockedFolder').removeClass('hide');
Prosper De Laure's avatar
Prosper De Laure committed
212
                $('#folderToolbarImport').addClass('hide');
213
            } else {
214
                this.folderPanel.find('.lockedFolder').addClass('hide');
Prosper De Laure's avatar
Prosper De Laure committed
215
                $('#folderToolbarImport').removeClass('hide');
Prosper De Laure's avatar
Prosper De Laure committed
216
217
            }

218
            if (locked) {
Prosper De Laure's avatar
Prosper De Laure committed
219
220
                $('#folderToolbarImport').attr('disabled', 'disabled');
            } else {
221
                $('#folderToolbarImport').removeAttr('disabled');
222
223
            }

Prosper De Laure's avatar
Prosper De Laure committed
224
            $.ajax({
225
                url         : url,
Prosper De Laure's avatar
Prosper De Laure committed
226
227
228
                type        : "GET",
                dataType    : 'json',
                success     : function (response) {
229
                    ArchiveFolderList.buildResultList(response.archives);
230
231
232
                    if (locked) {
                        ArchiveFolderList.folderPanel.find('.addChildrenArchive').remove();
                    }
Prosper De Laure's avatar
Prosper De Laure committed
233
234
235
236
237
238
                },
                error       : function (response) {
                    gritter.show(response.responseText, false);
                }
            })

239
240
241
242
243
244
245
246
247
248
249
250
251
252
            pathList = {};
            $.each(this.pathList, function(key, value) {
                var path = "";

                $.each(value, function(key, value) {
                    path += value[1] + ' / ';
                })

                pathList[key] = path;
            })

            this.pathList = pathList;


253
            this.buildNewArchiveDropdownMenu(archivalProfiles, acceptArchivesWithoutProfiles);
Jerome Boucher's avatar
Jerome Boucher committed
254

Alexis Ragot's avatar
Alexis Ragot committed
255
            $("#folderToolbarSearch").data("orgregnumber", orgRegNumber).data("folderid", folderId);
Prosper De Laure's avatar
Prosper De Laure committed
256
257
        },

258
259
260
261
262
263
264
265
266
        buildResultList: function(archives, options, showArchivePath) {
            // to inititate default value and avoid bug on IE 11
            if (options === undefined) {
                options = null;
            }
            if (showArchivePath === undefined) {
                showArchivePath = false;
            }

267
            trigger("clearDetail.recordsManagement");
268
            this.showArchivePath = showArchivePath;
Prosper De Laure's avatar
Prosper De Laure committed
269

Prosper De Laure's avatar
Prosper De Laure committed
270
            resultNumberText = "";
Prosper De Laure's avatar
Prosper De Laure committed
271
            if (archives.length) {
Alexandre Morin's avatar
Alexandre Morin committed
272
273
                $('#folderToolbarFreeze').removeAttr("disabled");
                $('#folderToolbarUnfreeze').removeAttr("disabled");
Alexis Ragot's avatar
Alexis Ragot committed
274
                $('#folderToolbarSearch').removeAttr("disabled");
Prosper De Laure's avatar
Prosper De Laure committed
275

Prosper De Laure's avatar
Prosper De Laure committed
276
            } else {
Alexandre Morin's avatar
Alexandre Morin committed
277
278
                $('#folderToolbarFreeze').attr("disabled", "disabled");
                $('#folderToolbarUnfreeze').attr("disabled", "disabled");
Alexis Ragot's avatar
Alexis Ragot committed
279
                $('#folderToolbarSearch').attr("disabled", "disabled");
280
            }
281

282
283
284
285
286
287
288
289
290
291
292
293
294
            defaultOptions = {
                datas: archives,
                rowMerge: ArchiveFolderList.mergeRow,
                rowMaxNumber: 10,
                rowTranslation: $('#rows_text').text(),
                emptyMessage: '<i class="text-muted"><br\/><span class="fa fa-times">&nbsp;<\/span>' + $('#emptyFolder_text').html() + '<\/i>',
                itemsName: [$('#archive_text').text(), $('#archives_text').text()],
                translation: {
                    First: $('#first_text').html(),
                    Previous: $('#previous_text').html(),
                    Next: $('#next_text').html(),
                    Last: $('#last_text').html()
                },
Prosper De Laure's avatar
Prosper De Laure committed
295
296
                sorting: [
                    {
297
298
299
                        fieldName: 'archiveName',
                        label: $('#archiveName_text').text(),
                        type: 'txt'
Prosper De Laure's avatar
Prosper De Laure committed
300
301
                    },
                    {
302
303
304
305
                        fieldName: 'depositDate',
                        label: $('#depositDate_text').text(),
                        type: 'num',
                        default: 'DESC'
306
                    }
Thomas Busser's avatar
Thomas Busser committed
307
                ],
308
309
310
311
312
313
314
315
316
317
318
                unsearchable: [
                    "status"
                ]
            };
            if(options){
                $.each(options, function( key, value ) {
                    defaultOptions[key] = value;
                })
            }

            $('#folderContentList').dataList(defaultOptions);
319

320
321
322
            if (!(FilePlan.selectedNode.hasClass('folder') && FilePlan.selectedNode.data('closed'))) {
                this.initDragNDrop();
            }
Prosper De Laure's avatar
Prosper De Laure committed
323
        },
324

Prosper De Laure's avatar
Prosper De Laure committed
325
        mergeRow: function(archive) {
326
            var archiveDiv = ArchiveFolderList.rowTemplate.clone();
327
            var icon = archiveDiv.find('.fileplanLevel');
Jerome Boucher's avatar
Jerome Boucher committed
328
329
330
331
            archiveDiv.attr('id', archive.archiveId);
            archiveDiv.find('.archiveName').text(archive.archiveName);
            archiveDiv.find('.status').text(archive.status);
            var siblings = archiveDiv.find('small');
332
333
334
335

            archiveDiv.attr('id', archive.archiveId)
                .find('.status').text(archive.status);

336
337
338
339
340
341
342
            switch (archive.fileplanLevel) {
                case 'item':
                    icon.addClass('fa fa-file');
                    break;

                case 'file':
                default:
Prosper De Laure's avatar
Prosper De Laure committed
343
                    icon.addClass('fa fa-archive');
344
            }
Jerome Boucher's avatar
Jerome Boucher committed
345
346
347

            if (archive.archivalProfileName) {
                $(siblings[0]).text(' ' + archive.archivalProfileName);
Prosper De Laure's avatar
Prosper De Laure committed
348
349
            }
            if (archive.originatorArchiveId) {
Jerome Boucher's avatar
Jerome Boucher committed
350
351
352
353
                $(siblings[1]).text(' ' + archive.originatorArchiveId);
            }
            if (archive.originatingDate) {
                $(siblings[2]).text(' ' + archive.originatingDate);
Prosper De Laure's avatar
Prosper De Laure committed
354
355
            }

356
357
358
359
            if (ArchiveFolderList.showArchivePath && ArchiveFolderList.pathList[archive.originatorOrgRegNumber]) {
                $(siblings[3]).children('span').text(ArchiveFolderList.pathList[archive.originatorOrgRegNumber]);
            }

Prosper De Laure's avatar
Prosper De Laure committed
360
            return archiveDiv;
361
362
        },

363
364
365
366
        initDragNDrop: function() {
            $('#folderContentList').find('.archive').draggable({
                revert : true,
                zIndex: 100,
367
                delay: 200,
368
369
370
371
372
373
374
375
376
377
378
379
380
381
                helper: function() {
                    var archive = $(this);
                    var archiveIds = [];
                    var helper = $('<div/>');
                    var title = ""

                    if (archive.hasClass('bg-info')) {
                        $('#folderContentList').find('.bg-info').each(function() {
                            archiveIds.push($(this).attr('id'));
                            title = archiveIds.length + ' ' + $('#archives_text').text();
                        })
                    } else {
                            archiveIds.push(archive.attr('id'));
                            title = archive.find('.archiveName').html();
382
383
                    }

384
385
386
387
                    helper.addClass('archiveHelper')
                        .data('archives', archiveIds)
                        .append($('<i/>').addClass("fa fa-archive")
                                         .css('text-align', 'center')
388
                                         .css('font-size', '30px'))
389
390
391
392
393
394
                        .append('<br/>')
                        .append(title)
                        .css('opacity', '0.8')
                        .css('color', 'grey')
                        .css('text-align', 'center');
                    return helper
395
396
                },
            cancel: ".fa"
397
398
            })
        },
Jerome Boucher's avatar
Jerome Boucher committed
399

Prosper De Laure's avatar
Prosper De Laure committed
400
401
        refresh: function() {
            trigger('loadFolder.filePlan', [this.orgRegNumber]);
402
403
        },

Prosper De Laure's avatar
Prosper De Laure committed
404
        show: function() {
405
            $('.folderContents').removeClass('hide');
406
            trigger("folderView.recordsManagement");
407
        },
408

409
        buildNewArchiveDropdownMenu: function(archivalProfiles, acceptArchivesWithoutProfiles) {
410
            var dropdown = $("#folderToolbarBtn .dropdown-menu");
411
            dropdown.children().remove();
412

413
            if (!acceptArchivesWithoutProfiles && archivalProfiles.length == 0) {
414
                $("#folderToolbarImport").addClass('hide');
415
416
                return;
            }
Jerome Boucher's avatar
Jerome Boucher committed
417

418
            if (acceptArchivesWithoutProfiles) {
Jerome Boucher's avatar
Jerome Boucher committed
419
                var a = $("<a/>")
420
421
422
                    .addClass("small newArchive")
                    .data("reference", '')
                    .attr('style', "cursor: pointer;")
Alexandre Morin's avatar
Alexandre Morin committed
423
                    .text($('#withoutProfile_text').text());
424
425
426
427

                $("<li/>").append(a).appendTo(dropdown);
            };

428
            for (var i = 0; i < archivalProfiles.length; i++) {
429
430
431
432
433
434
                var a = $("<a/>")
                    .addClass("userProfile small newArchive")
                    .data("reference", archivalProfiles[i].reference)
                    .data("json", archivalProfiles[i])
                    .attr('style', "cursor: pointer;")
                    .text(archivalProfiles[i].name);
Jerome Boucher's avatar
Jerome Boucher committed
435

436
437
                $("<li/>").append(a).appendTo(dropdown);
            }
438
439
        }
    }
440

441
    NewArchive = {
442
        loadImportForm: function(e) {
Prosper De Laure's avatar
Prosper De Laure committed
443
            $('#folderContents').addClass('hide');
444

445
            trigger('newArchiveForm.recordsManagement', [e.data('json'), ArchiveFolderList.orgRegNumber, ArchiveFolderList.folderId, e.data('parent-archive-id'), e.data('parent-archive-name')]);
446
        }
447
448
    }

449
    $("#folderPanel").on('click', '.newArchive', function() {
450
        Metadata.isModification = false;
451
        NewArchive.loadImportForm($(this));
452
    });
Jerome Boucher's avatar
Jerome Boucher committed
453

Prosper De Laure's avatar
Prosper De Laure committed
454
    // Actions on list
455
456
457
458
459
460
461
462
    $("#folderContentList").on('click', ".dataList-sorting", function() {
        ArchiveFolderList.initDragNDrop();
    });

    $("#folderContentList").on('keyup', "input", function() {
        ArchiveFolderList.initDragNDrop();
    });

463
464
465
    $("#folderContentList").on('click','.pagination li', function() {
        ArchiveFolderList.initDragNDrop();
    });
466

467
    $('#folderPanel').onEvent("loadFolder.recordsManagement", function(e, path, orgRegNumber, folderId, profiles, locked, acceptArchiveWithoutProfile, pathList) {
468
        ArchiveFolderList.show();
469
        FolderBreadcrumb.load(path);
470
        ArchiveFolderList.getfolderContents(orgRegNumber, folderId, profiles, locked, acceptArchiveWithoutProfile, pathList);
471
472
    })

Prosper De Laure's avatar
Prosper De Laure committed
473
474
475
476
    $('#folderPanel').onEvent("showFolder.recordsManagement", function() {
        ArchiveFolderList.show();
    })

Prosper De Laure's avatar
Prosper De Laure committed
477
478
479
480
    $('#folderPanel').onEvent("archiveImportOver.recordsManagement", function() {
        ArchiveFolderList.show();
    })

481
    $('#folderPanel').onEvent("showSearchResult.recordsManagement", function(e, archives) {
482
483
484
        var options = {
            itemsName: [$('#foundArchive_text').text(), $('#foundArchives_text').text()]
        };
485
        ArchiveFolderList.buildResultList(archives, options, true);
486
487
    })

Prosper De Laure's avatar
Prosper De Laure committed
488
    // Breadcrump
489
490
    $('#folderBreadcrumb').on('click', 'a', function() {
        FolderBreadcrumb.selectFolder($(this));
Prosper De Laure's avatar
Prosper De Laure committed
491
492
    })

493
494
495
496
497
498
499
500
    $('#folderBreadcrumb').onEvent("archiveImportStarted.recordsManagement", function() {
        FolderBreadcrumb.lockNavigation();
    })

    $('#folderBreadcrumb').onEvent("archiveImportOver.recordsManagement", function() {
        FolderBreadcrumb.unlockNavigation();
    })

Jerome Boucher's avatar
Jerome Boucher committed
501

502
</script>