folder.html 19.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="folderToolbar" 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
</div>

39
<div id="listTemplate" class="hide" data-translate-catalog="recordsManagement/message">
40
    <div class="archive row archiveItem" 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
59
        <?merge exportPrivilege.bool() ?>
        <div class="pull-right addChildrenArchive addingNew exportArchive hide">
60
            <button class="btn btn-xs btn-default" title="Export">
61
62
63
                <span class="fa fa-download"></span>
            </button>
        </div>
64
        <?merge depositPrivilege.bool() ?>
65
        <div class="pull-right dropdown addChildrenArchive addingNew hide">
66
67
68
69
            <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">
70
71
72
73
            </ul>
        </div>
        <div class="archiveContent hide">
            <ul class="tree-l">
74
75
            </ul>
        </div>
Cyril Vazquez's avatar
Cyril Vazquez committed
76
    </div>
Alexis Ragot's avatar
Alexis Ragot committed
77
</div>
78
79

<div class="hide">
80
    <span id="resultsOfSearch">Results of search in</span>
81
    <span id="archives_text">archives</span>
Prosper De Laure's avatar
Prosper De Laure committed
82
    <span id="archive_text">archive</span>
83
84
    <span id="foundArchives_text">archives found</span>
    <span id="foundArchive_text">archive found</span>
Prosper De Laure's avatar
Prosper De Laure committed
85
    <span id="rows_text">rows</span>
Prosper De Laure's avatar
Prosper De Laure committed
86
87
88
    <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
89
90
91
92
    <span id="first_text">First</span>
    <span id="previous_text">Previous</span>
    <span id="next_text">Next</span>
    <span id="last_text">Last</span>
93
    <span id="withoutProfile_text">Without profile</span>
Jerome Boucher's avatar
Jerome Boucher committed
94

95
</div>
96
97
98
99
100
101
102
<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
103
104
105
    }
</style>

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

109
110
    $("#folderToolbarCloseSearch").on('click', function(e) {
        trigger('folderView.recordsManagement');
111
        FilePlan.load($("#filePlanTree").find('.node-warning').closest('li'));
112
    });
113

114
    $("#folderToolbarBtn").onEvent("showSearchResult.recordsManagement", function (e) {
115
116
117
118
119
120
121
122
123
124
125
        ToolbarButtons.initSearchView();
    });

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

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

Prosper De Laure's avatar
Prosper De Laure committed
137
138
139
    FolderBreadcrumb = {
        breadcrumb    : $('#folderBreadcrumb'),
        load: function(path) {
140
            var height = 0;
Prosper De Laure's avatar
Prosper De Laure committed
141
142
            this.breadcrumb.html('');

143
144
145
146
147
148
            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
149
            }
Prosper De Laure's avatar
Prosper De Laure committed
150
151

            this.breadcrumb.find('li:last>a').data('orgregnumber', '');
152
153
154
155
156
157
158
159
            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
160

161
162
163
                var dropdown = $('<li/>').addClass('dropdown').append(dots).append(ul);

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

165
166
167
168
169
170
171
172
173
174
                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
175
176
        },

177
        buildLink: function(e, truncate) {
178
179
            var text = e[0];
            return $('<li/>').append($('<a/>').attr('href', '#').text(text).data('orgregnumber', e[1]));
180
        },
Prosper De Laure's avatar
Prosper De Laure committed
181

182
        selectFolder: function(e) {
Prosper De Laure's avatar
Prosper De Laure committed
183
184
            var orgRegNumber = e.data('orgregnumber');
            if (orgRegNumber) {
Prosper De Laure's avatar
Prosper De Laure committed
185
                trigger('loadFolder.filePlan', [orgRegNumber]);
Prosper De Laure's avatar
Prosper De Laure committed
186
            }
187
188
189
190
191
192
193
194
        },

        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
195
        }
196
    };
197
    ArchiveFolderList = {
Cyril Vazquez's avatar
Cyril Vazquez committed
198
        rowTemplate    : $('#listTemplate .archive').clone(),
Prosper De Laure's avatar
Prosper De Laure committed
199
200
201
        folderContents : $('#folderContentList'),
        folderPanel    : $('#folderPanel'),
        orgRegNumber   : null,
202
203
204
        folderId       : null,
        pathList       : [],
        showArchivePath: false,
205
        totalArchives: null,
206

207
        getfolderContents: function(orgRegNumber, folderId, archivalProfiles, disabled, locked, acceptArchivesWithoutProfiles, pathList) {
Prosper De Laure's avatar
Prosper De Laure committed
208
209
            this.orgRegNumber = orgRegNumber;
            this.folderId = folderId;
210
            this.pathList = pathList;
Prosper De Laure's avatar
Prosper De Laure committed
211
            this.show();
212
            $('#welcomMessage').addClass('hide')
213
            var url = "/folder?originatorOrgRegNumber="+orgRegNumber;
214
            if (folderId) {
215
                url = url + "&filePlanPosition="+folderId;
216
            }
217
            if (locked) {
218
                this.folderPanel.find('.lockedFolder').removeClass('hide');
Prosper De Laure's avatar
Prosper De Laure committed
219
                $('#folderToolbarImport').addClass('hide');
220
            } else {
221
                this.folderPanel.find('.lockedFolder').addClass('hide');
Prosper De Laure's avatar
Prosper De Laure committed
222
                $('#folderToolbarImport').removeClass('hide');
Prosper De Laure's avatar
Prosper De Laure committed
223
224
            }

225
            if (locked) {
Prosper De Laure's avatar
Prosper De Laure committed
226
227
                $('#folderToolbarImport').attr('disabled', 'disabled');
            } else {
228
                $('#folderToolbarImport').removeAttr('disabled');
229
230
            }

231
232
233
234
            if (disabled) {
                $('#folderToolbarImport').attr('disabled', 'disabled');
            }

Prosper De Laure's avatar
Prosper De Laure committed
235
            $.ajax({
236
                url         : url,
Prosper De Laure's avatar
Prosper De Laure committed
237
238
239
                type        : "GET",
                dataType    : 'json',
                success     : function (response) {
240
                    ArchiveFolderList.buildResultList(response.archives, null, false, response.countWithoutLimit);
241
                    if (locked || disabled) {
242
243
                        ArchiveFolderList.folderPanel.find('.addChildrenArchive').remove();
                    }
Prosper De Laure's avatar
Prosper De Laure committed
244
245
246
247
248
249
                },
                error       : function (response) {
                    gritter.show(response.responseText, false);
                }
            })

250
251
252
253
254
255
256
257
258
259
260
261
262
263
            pathList = {};
            $.each(this.pathList, function(key, value) {
                var path = "";

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

                pathList[key] = path;
            })

            this.pathList = pathList;


264
            this.buildNewArchiveDropdownMenu(archivalProfiles, acceptArchivesWithoutProfiles);
Jerome Boucher's avatar
Jerome Boucher committed
265

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

269
        buildResultList: function(archives, options, showArchivePath, totalResult) {
270
271
272
273
274
275
276
277
            // to inititate default value and avoid bug on IE 11
            if (options === undefined) {
                options = null;
            }
            if (showArchivePath === undefined) {
                showArchivePath = false;
            }

278
            trigger("clearDetail.recordsManagement");
279
            this.showArchivePath = showArchivePath;
Prosper De Laure's avatar
Prosper De Laure committed
280

Prosper De Laure's avatar
Prosper De Laure committed
281
            resultNumberText = "";
Prosper De Laure's avatar
Prosper De Laure committed
282
            if (archives.length) {
Alexandre Morin's avatar
Alexandre Morin committed
283
284
                $('#folderToolbarFreeze').removeAttr("disabled");
                $('#folderToolbarUnfreeze').removeAttr("disabled");
Alexis Ragot's avatar
Alexis Ragot committed
285
                $('#folderToolbarSearch').removeAttr("disabled");
Prosper De Laure's avatar
Prosper De Laure committed
286

Prosper De Laure's avatar
Prosper De Laure committed
287
            } else {
Alexandre Morin's avatar
Alexandre Morin committed
288
289
                $('#folderToolbarFreeze').attr("disabled", "disabled");
                $('#folderToolbarUnfreeze').attr("disabled", "disabled");
Alexis Ragot's avatar
Alexis Ragot committed
290
                $('#folderToolbarSearch').attr("disabled", "disabled");
291
            }
292

293
294
            defaultOptions = {
                datas: archives,
295
                total: totalResult,
296
                rowMerge: ArchiveFolderList.mergeRow,
297
                rowMaxNumber: ($('#fullTextSearchForm').find('[name=maxResults]').val() != 'undefined' ? parseInt($('#fullTextSearchForm').find('[name=maxResults]').val(), 10) : 10),
298
299
300
301
302
303
304
305
306
                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
307
308
                sorting: [
                    {
309
310
311
                        fieldName: 'archiveName',
                        label: $('#archiveName_text').text(),
                        type: 'txt'
Prosper De Laure's avatar
Prosper De Laure committed
312
313
                    },
                    {
314
315
316
317
                        fieldName: 'depositDate',
                        label: $('#depositDate_text').text(),
                        type: 'num',
                        default: 'DESC'
318
                    }
Thomas Busser's avatar
Thomas Busser committed
319
                ],
320
321
322
323
324
325
326
327
328
329
330
                unsearchable: [
                    "status"
                ]
            };
            if(options){
                $.each(options, function( key, value ) {
                    defaultOptions[key] = value;
                })
            }

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

332
333
334
            if (!(FilePlan.selectedNode.hasClass('folder') && FilePlan.selectedNode.data('closed'))) {
                this.initDragNDrop();
            }
Prosper De Laure's avatar
Prosper De Laure committed
335
        },
336

Prosper De Laure's avatar
Prosper De Laure committed
337
        mergeRow: function(archive) {
338
            var archiveDiv = ArchiveFolderList.rowTemplate.clone();
339
            var icon = archiveDiv.find('.fileplanLevel');
Jerome Boucher's avatar
Jerome Boucher committed
340
341
342
343
            archiveDiv.attr('id', archive.archiveId);
            archiveDiv.find('.archiveName').text(archive.archiveName);
            archiveDiv.find('.status').text(archive.status);
            var siblings = archiveDiv.find('small');
344
345
346
347

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

348
349
350
351
352
353
354
            switch (archive.fileplanLevel) {
                case 'item':
                    icon.addClass('fa fa-file');
                    break;

                case 'file':
                default:
Prosper De Laure's avatar
Prosper De Laure committed
355
                    icon.addClass('fa fa-archive');
356
            }
Jerome Boucher's avatar
Jerome Boucher committed
357
358
359

            if (archive.archivalProfileName) {
                $(siblings[0]).text(' ' + archive.archivalProfileName);
Prosper De Laure's avatar
Prosper De Laure committed
360
361
            }
            if (archive.originatorArchiveId) {
Jerome Boucher's avatar
Jerome Boucher committed
362
363
364
365
                $(siblings[1]).text(' ' + archive.originatorArchiveId);
            }
            if (archive.originatingDate) {
                $(siblings[2]).text(' ' + archive.originatingDate);
Prosper De Laure's avatar
Prosper De Laure committed
366
367
            }

368
369
370
371
            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
372
            return archiveDiv;
373
374
        },

375
376
377
378
        initDragNDrop: function() {
            $('#folderContentList').find('.archive').draggable({
                revert : true,
                zIndex: 100,
379
                delay: 200,
380
381
382
383
384
385
386
                helper: function() {
                    var archive = $(this);
                    var archiveIds = [];
                    var helper = $('<div/>');
                    var title = ""

                    if (archive.hasClass('bg-info')) {
387
                        $('#folderContentList').find('.archive.selected').each(function() {
388
389
390
391
392
393
                            archiveIds.push($(this).attr('id'));
                            title = archiveIds.length + ' ' + $('#archives_text').text();
                        })
                    } else {
                            archiveIds.push(archive.attr('id'));
                            title = archive.find('.archiveName').html();
394
395
                    }

396
397
398
399
                    helper.addClass('archiveHelper')
                        .data('archives', archiveIds)
                        .append($('<i/>').addClass("fa fa-archive")
                                         .css('text-align', 'center')
400
                                         .css('font-size', '30px'))
401
402
403
404
405
406
                        .append('<br/>')
                        .append(title)
                        .css('opacity', '0.8')
                        .css('color', 'grey')
                        .css('text-align', 'center');
                    return helper
407
408
                },
            cancel: ".fa"
409
410
            })
        },
Jerome Boucher's avatar
Jerome Boucher committed
411

Prosper De Laure's avatar
Prosper De Laure committed
412
413
        refresh: function() {
            trigger('loadFolder.filePlan', [this.orgRegNumber]);
414
415
        },

Prosper De Laure's avatar
Prosper De Laure committed
416
        show: function() {
417
            $('.folderContents').removeClass('hide');
418
            trigger("folderView.recordsManagement");
419
        },
420

421
        buildNewArchiveDropdownMenu: function(archivalProfiles, acceptArchivesWithoutProfiles) {
422
            var dropdown = $("#folderToolbarBtn .dropdown-menu");
423
            dropdown.children().remove();
424

425
            if (!acceptArchivesWithoutProfiles && archivalProfiles.length == 0) {
426
                $("#folderToolbarImport").addClass('hide');
427
428
                return;
            }
Jerome Boucher's avatar
Jerome Boucher committed
429

430
            if (acceptArchivesWithoutProfiles) {
Jerome Boucher's avatar
Jerome Boucher committed
431
                var a = $("<a/>")
432
433
434
                    .addClass("small newArchive")
                    .data("reference", '')
                    .attr('style', "cursor: pointer;")
Alexandre Morin's avatar
Alexandre Morin committed
435
                    .text($('#withoutProfile_text').text());
436
437
438
439

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

440
            for (var i = 0; i < archivalProfiles.length; i++) {
441
442
443
444
445
446
                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
447

448
449
                $("<li/>").append(a).appendTo(dropdown);
            }
450
451
        }
    }
452

453
    NewArchive = {
454
        loadImportForm: function(e, profileMetadata) {
Prosper De Laure's avatar
Prosper De Laure committed
455
            $('#folderContents').addClass('hide');
456
            trigger('newArchiveForm.recordsManagement', [profileMetadata, ArchiveFolderList.orgRegNumber, ArchiveFolderList.folderId, e.data('parent-archive-id'), e.data('parent-archive-name')]);
457
        }
458
459
    }

460
    $("#folderPanel").on('click', '.newArchive', function() {
461
        Metadata.isModification = false;
462
        var profile = $(this).parent().text().trim();
463
        var profileMetadata = FulltextSearchForm.loadArchivalProfile(profile);
464
        NewArchive.loadImportForm($(this), profileMetadata);
465
    });
Jerome Boucher's avatar
Jerome Boucher committed
466

Prosper De Laure's avatar
Prosper De Laure committed
467
    // Actions on list
468
469
470
471
472
473
474
475
    $("#folderContentList").on('click', ".dataList-sorting", function() {
        ArchiveFolderList.initDragNDrop();
    });

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

476
477
478
    $("#folderContentList").on('click','.pagination li', function() {
        ArchiveFolderList.initDragNDrop();
    });
479

480
    $('#folderPanel').onEvent("loadFolder.recordsManagement", function(e, path, orgRegNumber, folderId, profiles, disabled, locked, acceptArchiveWithoutProfile, pathList) {
481
        ArchiveFolderList.show();
482
        FolderBreadcrumb.load(path);
483
        ArchiveFolderList.getfolderContents(orgRegNumber, folderId, profiles, disabled, locked, acceptArchiveWithoutProfile, pathList);
484
485
    })

Prosper De Laure's avatar
Prosper De Laure committed
486
487
488
489
    $('#folderPanel').onEvent("showFolder.recordsManagement", function() {
        ArchiveFolderList.show();
    })

Prosper De Laure's avatar
Prosper De Laure committed
490
491
492
493
    $('#folderPanel').onEvent("archiveImportOver.recordsManagement", function() {
        ArchiveFolderList.show();
    })

494
    $('#folderPanel').onEvent("showSearchResult.recordsManagement", function(e, archives) {
495
496
497
        var options = {
            itemsName: [$('#foundArchive_text').text(), $('#foundArchives_text').text()]
        };
498
        ArchiveFolderList.buildResultList(archives, options, true);
499
500
    })

Prosper De Laure's avatar
Prosper De Laure committed
501
    // Breadcrump
502
503
    $('#folderBreadcrumb').on('click', 'a', function() {
        FolderBreadcrumb.selectFolder($(this));
Prosper De Laure's avatar
Prosper De Laure committed
504
505
    })

506
507
508
509
510
511
512
513
    $('#folderBreadcrumb').onEvent("archiveImportStarted.recordsManagement", function() {
        FolderBreadcrumb.lockNavigation();
    })

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

Jerome Boucher's avatar
Jerome Boucher committed
514

515
</script>