Skip to content

Commit

Permalink
js refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Dec 2, 2024
1 parent 3b8ecbf commit ace344f
Show file tree
Hide file tree
Showing 15 changed files with 500 additions and 494 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -571,3 +571,5 @@ export const calendarController = {
initEventDatepickers: initEventDatepickers,
initWidgetCalendar: initWidgetCalendar
};

export default calendarController;
88 changes: 42 additions & 46 deletions app/Domain/Calendar/Templates/showMyCalendar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,48 +130,46 @@ class="right"

<script type="module">
import "@mix('js/Domain/Calendar/Js/calendarController.js')";
jQuery(document).ready(function() {
var eventSources = [];
var events = {events: [
<?php foreach ($tpl->get('calendar') as $calendar) : ?>
{
title: <?php echo json_encode($calendar['title']); ?>,
start: new Date(<?php echo format($calendar['dateFrom'])->jsTimestamp() ?>),
<?php if (isset($calendar['dateTo'])) : ?>
end: new Date(<?php echo format($calendar['dateTo'])->jsTimestamp() ?>),
<?php endif; ?>
<?php if ((isset($calendar['allDay']) && $calendar['allDay'] === true)) : ?>
allDay: true,
<?php else : ?>
allDay: false,
<?php endif; ?>
entityId: <?php echo $calendar['id'] ?>,
<?php if (isset($calendar['eventType']) && $calendar['eventType'] == 'calendar') : ?>
url: '<?=CURRENT_URL ?>#/calendar/editEvent/<?php echo $calendar['id'] ?>',
backgroundColor: '<?= $calendar['backgroundColor'] ?? "var(--accent2)" ?>',
borderColor: '<?= $calendar['borderColor'] ?? "var(--accent2)" ?>',
entityType: "event",
<?php else : ?>
url: '<?=CURRENT_URL ?>#/tickets/showTicket/<?php echo $calendar['id'] ?>?projectId=<?php echo $calendar['projectId'] ?>',
backgroundColor: '<?= $calendar['backgroundColor'] ?? "var(--accent2)" ?>',
borderColor: '<?= $calendar['borderColor'] ?? "var(--accent2)" ?>',
entityType: "ticket",
<?php endif; ?>
},
<?php endforeach; ?>
]};
eventSources.push(events);
<?php
$externalCalendars = $tpl->get("externalCalendars");
foreach ($externalCalendars as $externalCalendar) { ?>
leantime.moduleLoader.load("@mix('js/Domain/Calendar/Js/calendarController')").then(function(module){
var eventSources = [];
var events = {events: [
<?php foreach ($tpl->get('calendar') as $calendar) : ?>
{
title: <?php echo json_encode($calendar['title']); ?>,
start: new Date(<?php echo format($calendar['dateFrom'])->jsTimestamp() ?>),
<?php if (isset($calendar['dateTo'])) : ?>
end: new Date(<?php echo format($calendar['dateTo'])->jsTimestamp() ?>),
<?php endif; ?>
<?php if ((isset($calendar['allDay']) && $calendar['allDay'] === true)) : ?>
allDay: true,
<?php else : ?>
allDay: false,
<?php endif; ?>
entityId: <?php echo $calendar['id'] ?>,
<?php if (isset($calendar['eventType']) && $calendar['eventType'] == 'calendar') : ?>
url: '<?=CURRENT_URL ?>#/calendar/editEvent/<?php echo $calendar['id'] ?>',
backgroundColor: '<?= $calendar['backgroundColor'] ?? "var(--accent2)" ?>',
borderColor: '<?= $calendar['borderColor'] ?? "var(--accent2)" ?>',
entityType: "event",
<?php else : ?>
url: '<?=CURRENT_URL ?>#/tickets/showTicket/<?php echo $calendar['id'] ?>?projectId=<?php echo $calendar['projectId'] ?>',
backgroundColor: '<?= $calendar['backgroundColor'] ?? "var(--accent2)" ?>',
borderColor: '<?= $calendar['borderColor'] ?? "var(--accent2)" ?>',
entityType: "ticket",
<?php endif; ?>
},
<?php endforeach; ?>
]};
eventSources.push(events);
<?php
$externalCalendars = $tpl->get("externalCalendars");
foreach ($externalCalendars as $externalCalendar) { ?>
eventSources.push(
{
url: '{{ BASE_URL }}/calendar/externalCal/<?=$externalCalendar['id'] ?>',
Expand All @@ -181,16 +179,14 @@ class="right"
}
);
<?php } ?>
<?php } ?>
calendarController.initShowMyCalendar(
document.getElementById('calendar'),
eventSources,
'<?=session("usersettings.submenuToggle.myCalendarView") ?>'
);
});
});
</script>

Expand Down
16 changes: 6 additions & 10 deletions app/Domain/Dashboard/Templates/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,19 @@

<script type="module">
@dispatchEvent('scripts.afterOpen')
leantime.moduleLoader.load("@mix('/js/Domain/Widgets/Js/widgetController')").then(()=>
widgetController.initGrid()
);
import "@mix('/js/Domain/Widgets/Js/widgetController.js')"
import "@mix('/js/Domain/Help/Js/helperController.js')"
jQuery(document).ready(function() {
widgetController.initGrid();
@if($completedOnboarding === false)
helperController.firstLoginModal();
leantime.moduleLoader.load("@mix('/js/Domain/Help/Js/helperController')").then(()=>
helperController.firstLoginModal()
);
@endif
@php(session(["usersettings.modals.homeDashboardTour" => 1]));
});
</script>

@endsection
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class="bigProjectSelector {{ $menuType == 'project' ? 'active' : '' }}"
<i class="fa fa-caret-down" aria-hidden="true"></i>
</x-slot:labelText>
<x-slot:card-content>
<div class="projectselector" id="mainProjectSelector">
<div class="projectselector w-96 h-fit" id="mainProjectSelector">
@include('menu::includes.projectSelectorDropdown', [])
</div>
</x-slot:card-content>
Expand Down
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
},
"devDependencies": {
"@babel/eslint-parser": "^7.22.15",
"@babel/plugin-proposal-unicode-property-regex": "^7.18.6",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/preset-env": "^7.26.0",
"@tailwindcss/nesting": "^0.0.0-insiders.565cd3e",
Expand Down
Loading

0 comments on commit ace344f

Please sign in to comment.