-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
Working on #2972 Template Conversion to Twig Format (calendar.php) #2984
Working on #2972 Template Conversion to Twig Format (calendar.php) #2984
Conversation
Part 1 - Adding an event
Part 2 - Editing an event
Part 3 - Moving event
Part 4 - Viewing an event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a big one! Great work so far 😄
calendar.php
Outdated
$years[] = $year; | ||
} | ||
|
||
$timezones = build_timezone_select("timezone", $timezone); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is worth making a Twig function - do we use the same function elsewhere (such as the User CP)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I'm aware it's the same everywhere. So it could be a Twig function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, sounds good. Not sure whether we should have a TimeDateExtension
for this and my_date
(and whether we have any other time/date related functions to add to it) or if we should just create a CoreExtension
/MybbExtension
with these kinds of functions...
calendar.php
Outdated
// Construct option list for years | ||
for ($year = my_date('Y'); $year < (my_date('Y') + 5); ++$year) { | ||
if ($year == $single_year) { | ||
$select['single_year'] = "selected=\"selected\""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to do this logic inside the view rather than building HTML in the backend code. Same goes with the other instances of this type of code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but I'm not sure how to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two options:
- Do the conditional check in Twig
- Set a variable such as
$select['single_year_selected'] = true
and in twig do something like:
<option{%if select.single_year_selected %} selected="selected"{%endif}/>
Option two is the easiest by far.
<tr> | ||
<td class="trow2" style="vertical-align: top;"><strong>{{ lang.event_date }}</strong></td> | ||
<td class="trow1"> | ||
<script type="text/javascript"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A note for @justinsoltesz @Eric-Jackson - would be nice to take this inline JS out. The less inline JS we have, the better in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be great if we could have none so that admins can use a CSP without unsafe-inline
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah same goes for inline CSS imo, which is happening after the conversion to Twig I believe. Not sure if it would be better to remove JS now, or wait until we're making the changes to the HTML for a responsive theme.
<dl style="margin-top: 0; margin-bottom: 0; width: 100%;"> | ||
<dt><input type="radio" name="type" value="single" {{ select.type_single }} id="type_single" onclick="toggleType();" /> <label for="type_single"><strong>{{ lang.type_single }}</strong></label></dt> | ||
<dd style="margin-top: 4px;" id="single_selects"> | ||
<select name="single_day"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a good idea to try and abstract this into a loop and possibly break it into a function or partial view or something?
Part 5 - Day view
Part 6 - Week view
Part 7 - Calendar
I've finished the conversion work on the calendar. Once I fix the above issues (I hope to do them tomorrow) this will be ready to merge. One thing I want to ask everyone, should we keep the $gobutton function? I've been including it so far as {{ gobutton|raw }} but it seems pointless. All it does is load a template that contains a submit button, something that can be done inline easily. |
I just moved it inline for the subscriptions template personally.
… On 13 Jan 2018, at 23:47, Paul Bender ***@***.***> wrote:
I've finished the conversion work on the calendar. Once I fix the above issues (I hope to do them tomorrow) this will be ready to merge.
One thing I want to ask everyone, should we keep the $gobutton function? I've been including it so far as {{ gobutton|raw }} but it seems pointless. All it does is load a template that contains a submit button, something that can be done inline easily.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
-Added selected and checked HTML to templates -Move day select options to array
That should be everything. If there are no other issues this can be merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Justa few more minor comments. This is a big bunch of templates, thanks a lot for working on it.
Note that I'm not sure the loop idea will work at all, but it's worth testing.
</select> | ||
| ||
<select name="single_month"> | ||
<option value="1"{% if select.single_month.1 %} selected="selected"{% endif %}>{{ lang.month_1 }}</option> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal, but repeated blocks like these where it's easy to forget to update a single number make me anxious. The problem with using a loop here would be the month language variable, right? If so, you an kind of cheat:
{% for i in 1..12 %}
<option value="{{ i }}"{% if select.single_month[i] %} selected="selected"{% endif %}>{{ attribute(lang, 'month_' ~ i) }}</option>
{% endfor %}
The trick here is using the []
square brackets for the condition, and the attribute
core Twig function to get the language variable (with string concatenation using the ~
operator).
I believe that should work, but I haven't tested it at all.
{% if calendar.prev_link %} | ||
<a href="{{ calendar.prev_link|raw }}">« {{ calendar.prev_month_name }} {{ calendar.prev_month_year }}</a> | ||
{% endif %} | ||
{% if calendar.sep == true %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could simplify this to {% if calendar.sep %}
, since you already use the short form for next_link
below (unless this can be a string or some other type or something...).
<select name="month"> | ||
<option value="{{ calendar.month }}">{{ calendar.currentmonth }}</option> | ||
<option value="{{ calendar.month }}">----------</option> | ||
<option value="1">{{ lang.alt_month_1 }}</option> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, could use the same loop trick I mentioned in the other template file hopefully.
inc/views/base/calendar/dayview.twig
Outdated
<select name="month"> | ||
<option value="{{ calendar.month }}">{{ calendar.currentmonth }}</option> | ||
<option value="{{ calendar.month }}">----------</option> | ||
<option value="1">{{ lang.alt_month_1 }}</option> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loop trick again 😉
<select name="month"> | ||
<option value="{{ calendar.week_from_month }}">{{ calendar.week_from_one }}</option> | ||
<option value="{{ calendar.week_from_month }}">----------</option> | ||
<option value="1">{{ lang.alt_month_1 }}</option> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loop again 😄
- Moved month select options to array - Split bottom calendar jump/month jump into seperate Twig file - Converted user stars to Twig
I've converted the most months to use for loops. The ones I didn't I moved to their own file and included it where necessary (so there's only one instance instead of four). |
Nice one, thanks. Looks much cleaner now! |
@PaulBender Can you update the template list in #2972 with the templates you've sorted with this? |
…2984) * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 1 - Adding an event * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 2 - Editing an event * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 3 - Moving event * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 4 - Viewing an event * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 5 - Day view * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 6 - Week view * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 7 - Calendar * Moved gobutton to inline * Code updates -Added selected and checked HTML to templates -Move day select options to array * More code updates - Moved month select options to array - Split bottom calendar jump/month jump into seperate Twig file - Converted user stars to Twig
mybb#2984) * Working on mybb#2972 Template Conversion to Twig Format (calendar.php) Part 1 - Adding an event * Working on mybb#2972 Template Conversion to Twig Format (calendar.php) Part 2 - Editing an event * Working on mybb#2972 Template Conversion to Twig Format (calendar.php) Part 3 - Moving event * Working on mybb#2972 Template Conversion to Twig Format (calendar.php) Part 4 - Viewing an event * Working on mybb#2972 Template Conversion to Twig Format (calendar.php) Part 5 - Day view * Working on mybb#2972 Template Conversion to Twig Format (calendar.php) Part 6 - Week view * Working on mybb#2972 Template Conversion to Twig Format (calendar.php) Part 7 - Calendar * Moved gobutton to inline * Code updates -Added selected and checked HTML to templates -Move day select options to array * More code updates - Moved month select options to array - Split bottom calendar jump/month jump into seperate Twig file - Converted user stars to Twig
mybb#2984) * Working on mybb#2972 Template Conversion to Twig Format (calendar.php) Part 1 - Adding an event * Working on mybb#2972 Template Conversion to Twig Format (calendar.php) Part 2 - Editing an event * Working on mybb#2972 Template Conversion to Twig Format (calendar.php) Part 3 - Moving event * Working on mybb#2972 Template Conversion to Twig Format (calendar.php) Part 4 - Viewing an event * Working on mybb#2972 Template Conversion to Twig Format (calendar.php) Part 5 - Day view * Working on mybb#2972 Template Conversion to Twig Format (calendar.php) Part 6 - Week view * Working on mybb#2972 Template Conversion to Twig Format (calendar.php) Part 7 - Calendar * Moved gobutton to inline * Code updates -Added selected and checked HTML to templates -Move day select options to array * More code updates - Moved month select options to array - Split bottom calendar jump/month jump into seperate Twig file - Converted user stars to Twig
…2984) * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 1 - Adding an event * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 2 - Editing an event * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 3 - Moving event * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 4 - Viewing an event * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 5 - Day view * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 6 - Week view * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 7 - Calendar * Moved gobutton to inline * Code updates -Added selected and checked HTML to templates -Move day select options to array * More code updates - Moved month select options to array - Split bottom calendar jump/month jump into seperate Twig file - Converted user stars to Twig
…2984) * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 1 - Adding an event * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 2 - Editing an event * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 3 - Moving event * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 4 - Viewing an event * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 5 - Day view * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 6 - Week view * Working on #2972 Template Conversion to Twig Format (calendar.php) Part 7 - Calendar * Moved gobutton to inline * Code updates -Added selected and checked HTML to templates -Move day select options to array * More code updates - Moved month select options to array - Split bottom calendar jump/month jump into seperate Twig file - Converted user stars to Twig
Working on #2972
This PR is for the calendar (calendar.php).