Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blade conversion #2602

Merged
merged 7 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/Domain/Goalcanvas/Controllers/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,18 @@ public function run()
}
}

// request
muhtasimhafiz marked this conversation as resolved.
Show resolved Hide resolved
// $filter['status'] = request('filter_status', session('filter_status', 'all'));
// session(['filter_status' => $filter['status']]);
// $filter['relates'] = request('filter_relates', session('filter_relates', 'all'));
// session(['filter_relates' => $filter['relates']]);

$filter['status'] = $_GET['filter_status'] ?? (session("filter_status") ?? 'all');
muhtasimhafiz marked this conversation as resolved.
Show resolved Hide resolved
session(["filter_status" => $filter['status']]);
$filter['relates'] = $_GET['filter_relates'] ?? (session("filter_relates") ?? 'all');
session(["filter_relates" => $filter['relates']]);

$this->tpl->assign('filter', $filter);
$this->tpl->assign('currentCanvas', $currentCanvasId);
$this->tpl->assign('goalStats', $goalAnalytics);
$this->tpl->assign('canvasIcon', $this->canvasRepo->getIcon());
Expand Down
1 change: 1 addition & 0 deletions app/Domain/Goalcanvas/Controllers/DelCanvasItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class DelCanvasItem extends \Leantime\Domain\Canvas\Controllers\DelCanvasItem
{
protected const CANVAS_NAME = 'goal';

muhtasimhafiz marked this conversation as resolved.
Show resolved Hide resolved
}

}
7 changes: 4 additions & 3 deletions app/Domain/Goalcanvas/Templates/bigRockDialog.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
<script>
jQuery(document).ready(function(){

@if (isset($_GET['closeModal']))
<?php if (isset($_GET['closeModal'])): ?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not @if ? This should be blade

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting syntax error in the editor, while using @if inside the script tag, might be vs setting issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solved

jQuery.nmTop().close();
@endif


<?php endif ?>

if(jQuery("#wikiTitle").val().length >= 2) {
jQuery("#saveBtn").removeAttr("disabled");
}else{
Expand Down
74 changes: 74 additions & 0 deletions app/Domain/Goalcanvas/Templates/canvasComment.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@extends($layout)
@section('content')

@php
muhtasimhafiz marked this conversation as resolved.
Show resolved Hide resolved

/**
* canvasComment.inc template - Generic template for comments
*
* Required variables:
* - $canvasName Name of current canvas
*/


$canvasName = "goal";
muhtasimhafiz marked this conversation as resolved.
Show resolved Hide resolved

$id = "";
if (isset($canvasItem['id']) && $canvasItem['id'] != '') {
$id = $canvasItem['id'];
}
@endphp

<script type="text/javascript">
window.onload = function() {
if (!window.jQuery) {
//It's not a modal
location.href = "<?= BASE_URL ?>/<?= $canvasName ?>canvas/showCanvas?showModal=<?php echo $canvasItem['id']; ?>";
muhtasimhafiz marked this conversation as resolved.
Show resolved Hide resolved
}
}
</script>

<div class="showDialogOnLoad" style="display:none;">

<h4 class="widgettitle title-light" style="padding-bottom: 0">
<i class="fas {{ $canvasTypes[$canvasItem['box']]['icon'] }}"></i>
{{ $canvasTypes[$canvasItem['box']]['title'] }}
</h4>
<hr style="margin-top: 5px; margin-bottom: 15px;">

{!! $tpl->displayNotification() !!}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to display notifications in blade files


<h5 style="padding-left: 40px"><strong>{{ $tpl->e($canvasItem['description']) }}</strong></h5>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$tpl->e() is not required when using {{ }} So you can just do `{{ $canvasItem['description'] }}


@if ($id !== '')
<br />
<input type="hidden" name="comment" value="1" />
<h4 class="widgettitle title-light">
<span class="fa fa-comments"></span>{{ $tpl->__('subtitles.discussion') }}
muhtasimhafiz marked this conversation as resolved.
Show resolved Hide resolved
</h4>
@php
marcelfolaron marked this conversation as resolved.
Show resolved Hide resolved
$tpl->assign("formUrl", "/{{ $canvasName }}canvas/editCanvasComment/" . $id . "");
$tpl->displaySubmodule('comments-generalComment');
@endphp
@endif
</div>


<script type="text/javascript">
jQuery(document).ready(function() {

leantime.editorController.initSimpleEditor();

<?php if (!$login::userIsAtLeast($roles::$editor)) { ?>
muhtasimhafiz marked this conversation as resolved.
Show resolved Hide resolved
leantime.authController.makeInputReadonly(".nyroModalCont");

<?php } ?>

<?php if ($login::userHasRole([$roles::$commenter])) { ?>
leantime.commentsController.enableCommenterForms();
<?php } ?>

})
</script>

@endsection
13 changes: 0 additions & 13 deletions app/Domain/Goalcanvas/Templates/canvasComment.tpl.php

This file was deleted.

182 changes: 182 additions & 0 deletions app/Domain/Goalcanvas/Templates/canvasDialog.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
@extends($layout)
@section('content')

@php

$canvasName = 'goal';

$canvasItem = $tpl->get('canvasItem');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$tpl->get is not required when using blade. You can access the variables directly ($canvasItem)

$canvasTypes = $tpl->get('canvasTypes');
$hiddenStatusLabels = $tpl->get('statusLabels');
$statusLabels = $statusLabels ?? $hiddenStatusLabels;
$hiddenRelatesLabels = $tpl->get('relatesLabels');
$relatesLabels = $relatesLabels ?? $hiddenRelatesLabels;
$dataLabels = $tpl->get('dataLabels');

$id = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to the controller

if (isset($canvasItem['id']) && $canvasItem['id'] != '') {
$id = $canvasItem['id'];
}

$currentCanvas = $tpl->get('currentCanvas');

if (isset($_GET['canvasId'])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move to controller

$currentCanvas = (int)$_GET['canvasId'];
}

@endphp

<script type="text/javascript">
window.onload = function() {
if (!window.jQuery) {
//It's not a modal
location.href = "<?= BASE_URL ?>/<?= $canvasName ?>canvas/showCanvas?showModal=<?php echo $canvasItem['id']; ?>";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace $canvasName with "goal" (and use blade: {{ }})

}
}
</script>

<div style="width:1000px">

<h1><i class="fas <?= $canvasTypes[$canvasItem['box']]['icon']; ?>"></i> <?= $canvasTypes[$canvasItem['box']]['title']; ?></h1>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with blade call {{ }}


{{ $tpl->displayNotification() }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove notification calls


<form class="formModal" method="post" action="{{ BASE_URL."/$canvasName/canvas/editCanvasItem/$id" }}">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$canvasName to be replaced with "goal"


<input type="hidden" value="{{ $currentCanvas }}" name="canvasId">
<input type="hidden" value="{{ $canvasItem['box'] }}" name="box" id="box">
<input type="hidden" value="{{ $id }}" name="itemId" id="itemId">
<input type="hidden" name="milestoneId" value="{{ $canvasItem['milestoneId'] ?? '' }}">
<input type="hidden" name="changeItem" value="1">

<div class="col-md-8">
<label>{{ __("label.what_is_your_goal") }}</label>
<input type="text" name="title" value="{{ $canvasItem['title'] }}" style="width:100%"><br>

@if (!empty($relatesLabels))
<label>{{ __("label.relates") }}</label>
<select name="relates" style="width: 50%" id="relatesCanvas">
</select><br>
@else
<input type="hidden" name="relates" value="{{ $canvasItem['relates'] ?? array_key_first($hiddenRelatesLabels) }}">
@endif
<br>
<h4 class="widgettitle title-light" style="margin-bottom:0px;"><i class="fa-solid fa-ranking-star"></i> {{ __("Metrics") }}</h4>

@php

$tpl->dispatchTplEvent('beforeMeasureGoalContainer', $canvasItem); @endphp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We created a blade directive for the dispatchEvent. Can you use:
@dispatchEvent('beforeMeasureGoalContainer', $canvasItem)

<div id="measureGoalContainer">
<label>How will you measure this objective. What metric will you be using.</label>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we are in the files: Can you move any english content into the language files in app/Language/en-US.ini at the bottom of the file. Then you can replace the strings with
{{ __('text.XXXXXX') }}

<input type="text" name="description" value="{{ $canvasItem['description'] }}" style="width:100%"><br>
</div>

<div class="row">
<div class="col-md-3">
<label>Starting Value</label>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use language file

<input type="number" step="0.01" name="startValue" value="{{ $canvasItem['startValue'] }}" style="width:105px">
</div>
<div class="col-md-3">
<label>Current Value</label>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use language file

<input type="number" step="0.01" name="currentValue" id="currentValueField" value="{{ $canvasItem['currentValue'] }}" @if ($canvasItem['setting']=='linkAndReport' ) readonly data-tippy-content="Current value calculated from child goals" @endif style="width:105px">
</div>
<div class="col-md-3">
<label>Goal Value</label>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use language file

<input type="number" step="0.01" name="endValue" value="{{ $canvasItem['endValue'] }}" style="width:105px">
</div>
<div class="col-md-3">
<label>Type</label>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use language file

<select name="metricType">
<option value="number" @if ($canvasItem['metricType']=='number' ) selected @endif>Number</option>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use language file. We should have existing labels for some of these. Please search translation file first

<option value="percent" @if ($canvasItem['metricType']=='percent' ) selected @endif>% Percent</option>
<option value="currency" @if ($canvasItem['metricType']=='currency' ) selected @endif>{{ __('language.currency') }}</option>
</select>
</div>
</div>

<br>
@if ($login::userIsAtLeast($roles::$editor))
<input type="submit" value="{{ __("buttons.save") }}" id="primaryCanvasSubmitButton">
<button type="submit" class="btn btn-primary" id="saveAndClose" value="closeModal" onclick="leantime.goalCanvasController.setCloseModal();">{{ __("buttons.save_and_close") }}</button>
@endif

@if ($id !== '')
<br><br><br>
<input type="hidden" name="comment" value="1">
<h4 class="widgettitle title-light"><span class="fa fa-comments"></span>{{ __('subtitles.discussion') }}</h4>
@php
$formUrl = "/strategyPro/editCanvasItem/" . $id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, seems the link is wrong. Can you replace the section with


        @include('comments.generalComment', ['formUrl' => "/goalcanvas/editCanvasComment/" . $id .])

@endphp
@include('comments.generalComment', ['formUrl' => $formUrl])
@endif
</div>

@if ($id != '')
<a href="{{ url("/$canvasName/canvas/delCanvasItem/$id") }}" class="formModal delete right">
muhtasimhafiz marked this conversation as resolved.
Show resolved Hide resolved
<i class='fa fa-trash-can'></i> {{ __("links.delete") }}
</a>
@endif

</form>


</div>

<script type="text/javascript">
jQuery(document).ready(function() {

leantime.dateController.initDateRangePicker(".startDate", ".endDate");

<?php if (!empty($statusLabels)) { ?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to blade syntax

new SlimSelect({
select: '#statusCanvas',
showSearch: false,
valuesUseText: false,
data: [
<?php foreach ($statusLabels as $key => $data) { ?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update to blade syntax

<?php if ($data['active']) { ?> {
innerHTML: '<?php echo "<i class=\"fas fa-fw " . $data["icon"] . "\"></i>&nbsp;" . $data['title']; ?>',
text: "<?= $data['title'] ?>",
value: "<?= $key ?>",
selected: <?php echo $canvasItem['status'] == $key ? 'true' : 'false'; ?>
},
<?php } ?>
<?php } ?>
]
});
<?php } ?>

<?php if (!empty($relatesLabels)) { ?>
muhtasimhafiz marked this conversation as resolved.
Show resolved Hide resolved
new SlimSelect({
select: '#relatesCanvas',
showSearch: false,
valuesUseText: false,
data: [
<?php foreach ($relatesLabels as $key => $data) { ?>
muhtasimhafiz marked this conversation as resolved.
Show resolved Hide resolved
<?php if ($data['active']) { ?> {
innerHTML: '<?php echo "<i class=\"fas fa-fw " . $data["icon"] . "\"></i>&nbsp;" . $data['title']; ?>',
text: "<?= $data['title'] ?>",
value: "<?= $key ?>",
selected: <?php echo $canvasItem['relates'] == $key ? 'true' : 'false'; ?>
},
<?php } ?>
<?php } ?>
]
});
<?php } ?>

leantime.editorController.initSimpleEditor();

<?php if (!$login::userIsAtLeast($roles::$editor)) { ?>
muhtasimhafiz marked this conversation as resolved.
Show resolved Hide resolved
leantime.authController.makeInputReadonly(".nyroModalCont");

<?php } ?>

<?php if ($login::userHasRole([$roles::$commenter])) { ?>
leantime.commentsController.enableCommenterForms();
<?php } ?>

})
</script>

@endsection
Loading
Loading