/** * Pages User Profile (jquery) */ 'use strict'; $(function () { // Projects table var dt_projects_table = $('.datatables-projects'); if (dt_projects_table.length) { var dt_project = dt_projects_table.DataTable({ ajax: assetsPath + 'json/user-profile.json', columns: [ { data: '' }, { data: 'id' }, { data: 'project_name' }, { data: 'project_leader' }, { data: '' }, { data: 'status' }, { data: '' } ], columnDefs: [ { // For Responsive className: 'control', searchable: false, orderable: false, responsivePriority: 2, targets: 0, render: function (data, type, full, meta) { return ''; } }, { // For Checkboxes targets: 1, orderable: false, searchable: false, responsivePriority: 3, checkboxes: true, render: function () { return ''; }, checkboxes: { selectAllRender: '' } }, { // Avatar image/badge, Name and post targets: 2, responsivePriority: 4, render: function (data, type, full, meta) { var $user_img = full['project_img'], $name = full['project_name'], $date = full['date']; if ($user_img) { // For Avatar image var $output = 'Avatar'; } else { // For Avatar badge var stateNum = Math.floor(Math.random() * 6); var states = ['success', 'danger', 'warning', 'info', 'primary', 'secondary']; var $state = states[stateNum], $name = full['project_name'], $initials = $name.match(/\b\w/g) || []; $initials = (($initials.shift() || '') + ($initials.pop() || '')).toUpperCase(); $output = '' + $initials + ''; } // Creates full output for row var $row_output = '
' + '
' + '
' + $output + '
' + '
' + '
' + '' + $name + '' + '' + $date + '' + '
' + '
'; return $row_output; } }, { // Teams targets: 4, orderable: false, searchable: false, render: function (data, type, full, meta) { var $team = full['team'], $output; $output = '
'; for (var i = 0; i < $team.length; i++) { $output += '
' + 'Avatar' + '
'; } $output += '
'; return $output; } }, { // Label targets: -2, render: function (data, type, full, meta) { var $status_number = full['status']; return ( '
' + '
' + '
' + '
' + '' + $status_number + '
' ); } }, { // Actions targets: -1, searchable: false, title: 'Actions', orderable: false, render: function (data, type, full, meta) { return ( '
' + '' + '' + '
' ); } } ], order: [[2, 'desc']], dom: '<"card-header pb-0 pt-sm-0"<"head-label text-center"><"d-flex justify-content-center justify-content-md-end"f>>t<"row mx-2"<"col-sm-12 col-md-6"i><"col-sm-12 col-md-6"p>>', displayLength: 7, lengthMenu: [7, 10, 25, 50, 75, 100], responsive: { details: { display: $.fn.dataTable.Responsive.display.modal({ header: function (row) { var data = row.data(); return 'Details of "' + data['project_name'] + '" Project'; } }), type: 'column', renderer: function (api, rowIdx, columns) { var data = $.map(columns, function (col, i) { return col.title !== '' // ? Do not show row in modal popup if title is blank (for check box) ? '' + '' + col.title + ':' + ' ' + '' + col.data + '' + '' : ''; }).join(''); return data ? $('').append(data) : false; } } } }); $('div.head-label').html('
Projects
'); } // Filter form control to default size // ? setTimeout used for multilingual table initialization setTimeout(() => { $('.dataTables_filter .form-control').removeClass('form-control-sm'); $('.dataTables_length .form-select').removeClass('form-select-sm'); }, 300); });