messageModal.html 9.68 KB
Newer Older
Prosper De Laure's avatar
Prosper De Laure committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<div id="messageModal" lang="en" data-translate-catalog="medona/messages">
    <div class="container-fluid">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4></h4>
        </div>
        <div class="modal-body">
            <div class="panel-group" id="messageAccordion" role="tablist" aria-multiselectable="true">
                <?merge messages ?>
                <div class="panel panel-info">
                    <div class="panel-heading" role="tab">
                        <h3 class="panel-title">
                            <h4>
                                <a data-toggle="collapse" data-parent="#messageAccordion" href="#message_[?merge .messageId?]" aria-expanded="true" aria-controls="[? .messageId ?]">
                                    <span><?merge .type ?></span>&nbsp;
                                    <small><?merge .date ?>
                                </a>
                                <div class="pull-right">

                                    <?merge .exportButton.bool() ?>
                                    <button type="button" class="btn btn-warning messageExport" data-action="[?merge .exportButton ?]" title="Download"><i class="fa fa-download">&nbsp;</i></button>
                                    <?merge .processButton.bool() ?>
                                    <button type="button" class="btn btn-warning messageAction" data-action="[?merge .processButton ?]" title="Process"><i class="fa fa-cogs">&nbsp;</i>Process</button>
                                    <?merge .acceptButton.bool() ?>
                                    <button type="button" class="btn btn-success messageAction" data-action="[?merge .acceptButton ?]" title="Accept"><i class="fa fa-check">&nbsp;</i>Accept</button>
26
27
                                    <?merge .acceptWarningButton.bool() ?>
                                    <button type="button" class="btn btn-success messageActionValidation" data-action="[?merge .acceptWarningButton ?]" title="Accept"><i class="fa fa-check">&nbsp;</i>Accept</button>
Prosper De Laure's avatar
Prosper De Laure committed
28
29
30
31
32
33
34
                                    <?merge .rejectButton.bool() ?>
                                    <button type="button" class="btn btn-danger messageActionReject" data-action="[?merge .rejectButton ?]" title="Reject"><i class="fa fa-times">&nbsp;</i>Reject</button>
                                    <?merge .validateButton.bool() ?>
                                    <button type="button" class="btn btn-success messageAction" data-action="[?merge .validateButton ?]" title="Validate" ><i class="fa fa-check">&nbsp;</i>Validate</button>
                                    <?merge .modifyButton.bool() ?>
                                    <button type="button" class="btn btn-warning messageAction" data-action="[?merge .modifyButton ?]" title="Modify"><i class="fa fa-times">&nbsp;</i>Modify</button>
                                    <?merge .validationButton.bool() ?>
Alexandre Morin's avatar
Alexandre Morin committed
35
                                    <button type="button" class="btn btn-danger messageActionValidation" data-action="[?merge .validationButton ?]" title="Destroy" ><i class="fa fa-trash">&nbsp;</i>Destroy</button>
Prosper De Laure's avatar
Prosper De Laure committed
36
37
38
39
                                    <?merge .sendRequestAuth.bool() ?>
                                    <button type="button" class="btn btn-warning messageAction" data-action="[?merge .sendRequestAuth ?]" title="Authorization"><i class="fa fa-level-up">&nbsp;</i>Authorization</button>
                                    <?merge .archived ?>
                                    <button type="button" class="btn btn-success viewArchive" data-archive-id="[?merge .messageId ?]" title="Info"><span class="fa fa-info-circle"></span></button>
Alexandre Morin's avatar
Alexandre Morin committed
40
41
                                    <?merge .acknowledgeButton.bool() ?>
                                    <button type="button" class="btn btn-danger messageActionValidation" data-action="[?merge .acknowledgeButton ?]" title="Acknowledge"><i class="fa fa-gavel">&nbsp;</i>Acknowledge</button>
Prosper De Laure's avatar
Prosper De Laure committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
                                </div>
                            </h4>
                        </h3>
                    </div>
                    <div id="message_[?merge .messageId ?]" class="panel-collapse collapse [?merge .last.bool().then('in', '') ?]" role="tabpanel">
                        <div class="panel-body">
                            <div class="dataObjects col-xs-12" id="[?merge .messageId ?]">
                                <!-- Data objects -->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <button type="button" id="closeModal" class="btn btn-default" data-dismiss="modal" title="Close">Close</button>
        </div>
    </div>
</div>

<!-- Data objects -->
<script type="text/javascript">
    $('#messageModal').on('click','.showDocument', function() {
        messageId = $(this).closest('.dataObjects').attr('id');
66
67
68
69
70
71
72
73

        filename = $(this).data('filename');

        if (!filename) {
            filename = "document";
        } else {
            filename = filename.substr(0, filename.lastIndexOf('.')) || filename;
        }
74
75
        var regEx = new RegExp('[ .]', 'gi');
        window.open("/medona/message/" + messageId + "/attachment/" + $(this).data('id') + "/" + filename.replace(regEx, "_"));
Prosper De Laure's avatar
Prosper De Laure committed
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
    })

    $('#messageModal').on('click','.showResource', function() {
        docId = $(this).closest('.relatedData').data('docid');
        window.open("/recordsManagement/digitalResource/" + docId + '/' + $(this).data('id'));
    })
    
    $('#messageModal').on('click','.viewArchive', function() {
        archiveInfoModal.load($(this).data('archive-id'));
    });

    $('#messageModal').on('click', ".messageActionReject", function() {
        var str = $(this).data('action');
        var res = str.split("/");

        loadReject(res[2],str);
    });
    
    $('#messageModal').on('click', ".messageActionValidation", function() {
        var parameters = {
            messageAction: $(this).data('action')
        };
        
Alexandre Morin's avatar
Alexandre Morin committed
99
100
        
        var res = parameters.messageAction.split("/");
101
102
103
        var last = res.pop();
        
        if ( last == "Acknowledge") {
104
            $('#confirmationModal').find('.modal-body').html($('#acknowledge_text').html());
105
106
107
108
            $('#confirmationModal').find('.modal-title').html($('#restitutionTitle_text').html());
        } else if (last == "Accept") {
            $('#confirmationModal').find('.modal-body').html($('#validation_text').html());
            $('#confirmationModal').find('.modal-title').html($('#restitutionTitle_text').html());
Alexandre Morin's avatar
Alexandre Morin committed
109
        } else {
110
            $('#confirmationModal').find('.modal-body').html($('#destroy_text').html());
111
            $('#confirmationModal').find('.modal-title').html($('#destructionTitle_text').html());
Alexandre Morin's avatar
Alexandre Morin committed
112
        }
113
        $('#confirmationModal').modal();
Prosper De Laure's avatar
Prosper De Laure committed
114
115
116
117
118
119
120
121
122
123
124
125
        
        $('#confirmDelete').one('click', function(){
                $.ajax({
                    url         : parameters.messageAction,
                    type        : 'PUT',
                    contentType : "application/json",
                    data        : JSON.stringify(parameters),
                    dataType    :'json',
                    success     : function (response) {
                        gritter.show(response.message, response.status, response.errors)
                        $('#infoModal').modal("hide");
                        $('#infoModal').one('hidden.bs.modal', function() {
126
                            MessageList.reloadList();
Prosper De Laure's avatar
Prosper De Laure committed
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
                        });
                    },
                    error       : function(response) {
                        gritter.show(response.responseJSON.message, response.responseJSON.status, response.responseJSON.errors);
                    }
                });
        });
    });
    
    $('#messageModal').on('click', ".messageAction", function() {
        var parameters = {
            messageAction: $(this).data('action')
        };

        ajax($(this), {
            url         : $(this).data('action'),
            type        : 'PUT',
            contentType : "application/json",
            data        : JSON.stringify(parameters),
            dataType    :'json',
            success     : function (response) {
                gritter.show(response.message, response.status, response.errors);
                $('#infoModal').modal("hide");
                $('#infoModal').one('hidden.bs.modal', function() {
                    MessageList.reloadList();
                });
            },
            error       : function(response) {
155
156
157
158
                $('#infoModal').modal("hide");
                $('#infoModal').one('hidden.bs.modal', function() {
                    MessageList.reloadList();
                });
Prosper De Laure's avatar
Prosper De Laure committed
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
                gritter.show(response.responseJSON.message, response.responseJSON.status, response.responseJSON.errors);
            }
        });
    });

    $('#messageModal').on('click', ".messageExport", function() {
        var messageAction = $(this).data('action');

        window.open(messageAction,'_blank');
        
        $('#infoModal').modal("hide");
        $('#infoModal').one('hidden.bs.modal', function() {
            MessageList.reloadList();
        });
    });
    
    $('#messageModal').on('click', ".archiveDescription", function() {
        $.ajax({
            type: "GET",
            url: "/recordsManagement/archiveDescription/" + $(this).data('archiveid'),
            dataType: 'html',
            success: function (response) {
                $('#modalContainerInfo').html(response);
                $('#viewModalInfo').modal();
            }
        });
    });
    
</script>