From 08523f620475c08939355fe7b629f5fc04ac56f6 Mon Sep 17 00:00:00 2001 From: muahahahh Date: Sun, 3 Jan 2021 18:14:50 +0100 Subject: [PATCH] added links --- db.sqlite3 | Bin 176128 -> 176128 bytes hr_module/__pycache__/urls.cpython-38.pyc | Bin 665 -> 716 bytes hr_module/__pycache__/views.cpython-38.pyc | Bin 7170 -> 7461 bytes .../__pycache__/misc.cpython-38.pyc | Bin 0 -> 643 bytes hr_module/handling_functions/misc.py | 8 +++ hr_module/static/css/calendar.css | 3 - .../css/hr_module_change_employee_data.css | 25 +++++++ ...dule.css => hr_module_create_schedule.css} | 0 hr_module/static/css/hr_module_import.css | 1 - .../static/css/hr_module_show_schedule.css | 34 +++++++--- hr_module/static/js/csrf_token.js | 17 +++++ .../js/hr_module_change_employee_data.js | 61 ++++++++++++++++++ ...hedule.js => hr_module_create_schedule.js} | 21 +----- .../static/js/hr_module_show_schedule.js | 53 ++++++++------- hr_module/static/js/tmp.js | 42 ------------ hr_module/templates/hr_module_base.html | 20 +++++- .../hr_module_change_employee_data.html | 20 ++++++ ...le.html => hr_module_create_schedule.html} | 6 +- hr_module/urls.py | 10 +-- hr_module/views.py | 37 +++++++---- 20 files changed, 240 insertions(+), 118 deletions(-) create mode 100644 hr_module/handling_functions/__pycache__/misc.cpython-38.pyc create mode 100644 hr_module/handling_functions/misc.py create mode 100644 hr_module/static/css/hr_module_change_employee_data.css rename hr_module/static/css/{hr_module_schedule.css => hr_module_create_schedule.css} (100%) create mode 100644 hr_module/static/js/csrf_token.js create mode 100644 hr_module/static/js/hr_module_change_employee_data.js rename hr_module/static/js/{hr_module_schedule.js => hr_module_create_schedule.js} (93%) delete mode 100644 hr_module/static/js/tmp.js create mode 100644 hr_module/templates/hr_module_change_employee_data.html rename hr_module/templates/{hr_module_schedule.html => hr_module_create_schedule.html} (89%) diff --git a/db.sqlite3 b/db.sqlite3 index 77bfa1d18e7bf2c97efab1e052c2a86ca92b36d2..87485472dc36c218784fd04cd946baa19cc00f54 100644 GIT binary patch delta 143 zcmZp8z}4`8Yl1Z6!HF`?j0YPNS`!$zCNM4GSK{V7#=!rH|1tj+{-gW~{DS;Ue4qKA z@LlCQ27}wx1eiGaSr`}?rcDkMm^8gpo{4Y!WqBq;10`UK2&CQg19eqRRu>AU5aBw2YG7#M6O2MSnBKPJb-r^my`tjL(1 zU!Is#oSm7K$c@V7LgjL9KPt~;Z=fW={hNXRJpVlYTz(rqcRn%Rr@UKun|T#^KJe`4 z>Ensz(b=vRz@)>=!dJmy2((LASf7`jK~Yv#RME)5$WYh7NY}u4`ob6{`Fb97aU%mm zDKBG6^#= P907Xlz;>H>rXv9W<$Y@1 diff --git a/hr_module/__pycache__/urls.cpython-38.pyc b/hr_module/__pycache__/urls.cpython-38.pyc index 9af6a64cd1d212fb5f21c5981ac510da57c901bc..424aa277a3fdf82284d4ce9a757267700d568745 100644 GIT binary patch delta 401 zcmZwDze~eF6bJBJW163LNhL#ZbdZ*g#Zl<&;2^kU2}jMLUdWs2`-Cu&fDwZn5l>7D^ zc+b`Jzgs=vVx9~;GP{%>ZbAAO*VeXNxelG>WFku9eQ^%#!%s{tXkgpLN?v2 WB~$&74yU7Yax^@SrVe3*{rm#vAZeoj delta 344 zcmX@ZI+Im9l$V!_0SHbceTd({#K7f2kjIh21Lg4od7LS{P#zzU$CbhlrE^5_ zrU(TyXbQgsxkZ!l7E3{5Nyf{G?=;n;IEs@qQd3HEQbEFbiMgp!+?lxr`9&r1DTyVC zx7dnP6N{2FCfhPPNJQ}#XXKa1!!$$*rsfvp{EAV7JBl--C>~bX zw_kbiYW`v_mr1~{=gAX$b?R=uO#ZpM?@ZgzSviuR37YcqRv{jXR*`Dd^!ogMtKT26 z2K+&5FxE+XL;kQe9LpJRn?GWW_@maSU$RQ^T(39gm#y-;y^2+#S(^JeVU5!~Ex@>) z7HJ=hJ7_;0fN_GpJV=K?*hz=!HW(-A2pxrS7cJ2-7^i5NR$$ys$LV$$_t4Z_qPjzx zHhv}u7{p1qM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a&b^LjhE+9|@3&B&Mv>AG{ tAq_Gi@|M!4qc8Og-uA%`fINvF9Wqda2Qm@Y6Z%12*GKgi^gfV_{{ied|I+{f diff --git a/hr_module/handling_functions/__pycache__/misc.cpython-38.pyc b/hr_module/handling_functions/__pycache__/misc.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3cbdcbf991c00778f8fd916dbc50709537dcac00 GIT binary patch literal 643 zcmZWnv2N5r5S>{cm(y_(h|q+}70At*4>+ADXlPJGlm-c%tX(_jXzew-Yfw&?>LLLR z5`RF-d=SkRG*l_0bQHjh%^?sY&Ft*#zS()tKHA+K1KG!~*NZQ-e&fyGCTR17+)XGb zPLs8%hoz$j61ACkNK6prbsSCcbbqk?_-Bwi1wIbP8T zTtXs(m_81XG} { + return response.json(); + }).then((data) => { + console.log(data); + loadValuesIntoPage(data) + }); +} + +function loadValuesIntoPage(data){ + var order = ['username', 'first_name', 'last_name', 'email', 'department', 'manager_username', 'time_model_id', 'manager_flag', 'is_active', 'is_staff', 'is_superuser'] + + var informationContainer = document.getElementById('search_results') + + for (var i = 0; i < order.length; i++){ + var field = order[i] + var value = data[field] + + var fieldContainer = document.createElement('div') + fieldContainer.className = 'field_container' + + if (typeof(value) === 'boolean'){ + var httpfield = document.createElement('input') + httpfield.type = 'checkbox' + httpfield.checked = value + httpfield.setAttribute('disabled', 'disabled') + } else { + var httpfield = document.createElement('div') + httpfield.innerHTML = value + } + var label = document.createElement('label') + label.setAttribute('for', field) + label.innerText = field.replace('_', ' ') + httpfield.id = field + httpfield.className = 'database_field' + + fieldContainer.appendChild(label) + fieldContainer.appendChild(httpfield) + informationContainer.appendChild(fieldContainer) + } +} \ No newline at end of file diff --git a/hr_module/static/js/hr_module_schedule.js b/hr_module/static/js/hr_module_create_schedule.js similarity index 93% rename from hr_module/static/js/hr_module_schedule.js rename to hr_module/static/js/hr_module_create_schedule.js index 6f07153..f800718 100644 --- a/hr_module/static/js/hr_module_schedule.js +++ b/hr_module/static/js/hr_module_create_schedule.js @@ -1,4 +1,3 @@ -const csrftoken = getCookie('csrftoken'); var searchInput = document.getElementById('searched_string'); searchInput.addEventListener("click", fetchSearchOptions); @@ -11,7 +10,7 @@ submitToDb.addEventListener('click', postPlanToDb); function fetchSearchOptions() { var host = 'http://' + window.location.host; - var fetch_url = host + '/hr_module/search' + var fetch_url = host + '/hr_module/search_api' var searched_field = document.getElementById('schedule_filter_category').value var searched_string = document.getElementById('searched_string').value @@ -235,24 +234,6 @@ function postPlanToDb(){ } - -function getCookie(name) { - let cookieValue = null; - if (document.cookie && document.cookie !== '') { - let cookies = document.cookie.split(';'); - for (let i = 0; i < cookies.length; i++) { - let cookie = cookies[i].trim(); - - if (cookie.substring(0, name.length + 1) === (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; -} - - function showPopup(){ document.getElementById("popup_content").addEventListener("click", function(e) { e.stopPropagation(); diff --git a/hr_module/static/js/hr_module_show_schedule.js b/hr_module/static/js/hr_module_show_schedule.js index 5fb287e..9f67999 100644 --- a/hr_module/static/js/hr_module_show_schedule.js +++ b/hr_module/static/js/hr_module_show_schedule.js @@ -1,4 +1,3 @@ -const csrftoken = getCookie('csrftoken'); var parent = document.getElementById('calendar_box') document.onload = parent.appendChild(addCalendar(monthsAhead=3)) @@ -86,34 +85,26 @@ function createDetailedCalendarRecords(data){ row.setAttribute('database_username', username) var cell = row.insertCell(0) - var dateInput = document.createElement('input') - dateInput.type = 'date' - dateInput.readOnly = true - dateInput.value = processedDate + var dateInput = document.createElement('div') + dateInput.innerText = processedDate dateInput.name = 'date' cell.appendChild(dateInput) var cell = row.insertCell(1) - var timeInput = document.createElement('input') - timeInput.type = 'time' - timeInput.readOnly = true - timeInput.value = processedBeginTime - timeInput.name = 'begin_time' + var timeInput = document.createElement('div') + timeInput.innerText = processedBeginTime + timeInput.className = 'begin_time' cell.appendChild(timeInput) var cell = row.insertCell(2) - var timeInput = document.createElement('input') - timeInput.type = 'time' - timeInput.readOnly = true - timeInput.value = processedEndTime - timeInput.name = 'end_time' + var timeInput = document.createElement('div') + timeInput.innerText = processedEndTime + timeInput.className = 'end_time' cell.appendChild(timeInput) var cell = row.insertCell(3) - var textInput = document.createElement('input') - textInput.type = 'text' - textInput.readOnly = true - textInput.value = processedActivityType + var textInput = document.createElement('div') + textInput.innerText = processedActivityType textInput.name = 'activity_type' cell.appendChild(textInput) @@ -144,10 +135,18 @@ function unlockRecordsForEditing(event){ var databaseId = event.target.value var parent = event.target.parentElement var row = document.getElementById('database_id_' + databaseId.toString()) - var children = row.getElementsByTagName('input') + var children = row.getElementsByTagName('div') for (var i = 0; i < children.length; i++){ - if (children[i].getAttribute('type') == 'time') { - children[i].readOnly = false; + console.log(children[i].className ) + if (['begin_time', 'end_time'].includes(children[i].className)) { + var value = children[i].innerText + var name = children[i].className + var input = document.createElement('input') + input.name = name + input.value = value + input.type = 'time' + children[i].innerHTML = '' + children[i].appendChild(input) } } @@ -229,6 +228,8 @@ function unhideCheckboxes(databaseId){ checkboxes[i].firstChild.checked = 'true' } } + var header_copy_over = document.getElementById('header_copy_over') + header_copy_over.style.display = 'table-cell' } function removeEditButtons(id){ @@ -277,13 +278,19 @@ function addCancelButton(databaseId){ function createDetailedHeaders(){ var table = document.createElement('table') let headerRow = document.createElement('tr') - let columns = ['Date', 'Start time', 'End time', 'Activity type', '', ''] + let columns = ['Date', 'Start time', 'End time', 'Activity type', 'Action', 'Copy over'] for (let i = 0; i < columns.length; i++){ var headerCell = document.createElement('th') var headerText = document.createElement('div') headerText.innerText = columns[i] headerCell.appendChild(headerText) + if (i == columns.length -1){ + headerCell.style.display = 'none' + headerCell.id = 'header_copy_over' + } + headerRow.appendChild(headerCell) + } table.appendChild(headerRow) table.id = 'detailed_plan_records' diff --git a/hr_module/static/js/tmp.js b/hr_module/static/js/tmp.js deleted file mode 100644 index da9db02..0000000 --- a/hr_module/static/js/tmp.js +++ /dev/null @@ -1,42 +0,0 @@ -var container = document.createElement('div') - container.id = 'calendar_container' - - var monthsBlock = document.createElement('div') - monthsBlock.id = 'months_block' - - renderCalendarFor(monthsBlock, currentYear, currentMonth, monthsAhead, 1) - - var buttonBack = createButton('calendar_button_back', 'calendar_button', '<') - buttonBack.addEventListener('click', function(){ - if (currentMonth == 1){ - currentMonth = 11 - currentYear = currentYear - 1 - } - renderCalendarFor(monthsBlock, currentYear, currentMonth, monthsAhead, 1) - }) - - - container.appendChild(buttonBack) - container.appendChild(monthsBlock) - - var buttonForward = createButton('calendar_button_forwards', 'calendar_button', '>') - buttonForward.addEventListener('click', function(){ - if (currentMonth == 12){ - currentMonth = 0 - currentYear = currentYear + 1 - } - renderCalendarFor(monthsBlock, currentYear, currentMonth, monthsAhead, 1) - }) - - container.appendChild(buttonForward) - - - - var buttonGoToDate = document.getElementById('button_load_selected_months') - buttonGoToDate.addEventListener('click', function(){ - var currentYear = parseInt(document.getElementById('year_selector').value) - var currentMonth = parseInt(document.getElementById('month_selector').value) - addCalendar(container, monthsAhead, currentMonth + 1, currentYear) - }) - - formatCalendarContainerSize() \ No newline at end of file diff --git a/hr_module/templates/hr_module_base.html b/hr_module/templates/hr_module_base.html index 8ca9e34..9ad7294 100644 --- a/hr_module/templates/hr_module_base.html +++ b/hr_module/templates/hr_module_base.html @@ -10,17 +10,31 @@ {% block core_content %}