Skip to content

Commit

Permalink
#2611 Route publishing page now shows a publishing section along with…
Browse files Browse the repository at this point in the history
… a datetime selector.
  • Loading branch information
Wotuu committed Nov 15, 2024
1 parent 3e9c3d5 commit e15cd17
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 14 deletions.
1 change: 1 addition & 0 deletions lang/en_US/js.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@
'floorunion_rotation_label' => 'Rotation',
'floorunionarea_floor_union_id_label' => 'Floor Union ID',
'actions_label' => 'Actions',
'scheduling_label' => 'Scheduling',
'add_to_team_label' => 'Add to team...',
'view_label' => 'View',
'collaborator_label' => 'Edit',
Expand Down
12 changes: 12 additions & 0 deletions resources/assets/js/custom/inline/dungeonroute/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class DungeonrouteTable extends InlineCode {
this._viewMode = 'biglist';
this._dt = null;

/** @type TableView */
this._tableView = null;
this._routeData = [];
// Handles the displaying of tags inside the table
Expand Down Expand Up @@ -87,6 +88,10 @@ class DungeonrouteTable extends InlineCode {
this._tableView = new TeamTableView();
break;
}
case 'team_route_publishing': {
this._tableView = new TeamRoutePublishingTableView();
break;
}
case 'routes': {
this._tableView = new RoutesTableView();
break;
Expand Down Expand Up @@ -476,6 +481,13 @@ class DungeonrouteTable extends InlineCode {
}
return result;
}
},
scheduling: {
'title': lang.get('messages.scheduling_label'),
'render': function (data, type, row, meta) {
let template = Handlebars.templates['team_dungeonroute_table_route_publishing_actions_template'];
return template($.extend({}, getHandlebarsDefaultVariables(), {public_key: row.public_key}));
}
}
};

Expand Down
70 changes: 70 additions & 0 deletions resources/assets/js/custom/inline/dungeonroute/tableview.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,73 @@ class TeamTableView extends TableView {
return 'team';
}
}


class TeamRoutePublishingTableView extends TableView {
constructor() {
super();

this._teamPublicKey = '';
this._isUserModerator = false;
}

/**
* Set the team ID (for filtering purposes)
* @param value
*/
setTeamPublicKey(value) {
this._teamPublicKey = value;
}

setIsUserModerator(value) {
this._isUserModerator = value;
}

/**
* Gets the Id of the team that was set for this view.
* @returns {*}
*/
getTeamPublicKey() {
return this._teamPublicKey;
}

/**
* Get the parameters when sending the AJAX request
* @returns {{team_public_key: *}}
*/
getAjaxParameters() {
return {team_public_key: this._teamPublicKey};
}

getColumns(view) {
let defaultDungeonId = $('#dungeonroute_search_dungeon_id').val();

this._columns = {
list: [
{name: 'title', width: '15%'},
{name: 'dungeon', width: '15%', defaultSearch: defaultDungeonId},
{name: 'features', width: '25%', className: 'd-none d-lg-table-cell'},
// {name: 'setup', width: '15%'},
{name: 'enemy_forces', width: '10%'},
],
biglist: [
{name: 'preview', width: '15%', clickable: false},
{name: 'title', width: '15%'},
{name: 'dungeon', width: '15%', className: 'd-none d-lg-table-cell', defaultSearch: defaultDungeonId},
{name: 'features', width: '25%', className: 'd-none d-lg-table-cell'},
]
};

// Push different columns based on if add mode is enabled or not
if (this._isUserModerator) {
this._columns.list.push({name: 'scheduling', width: '15%', clickable: false});
this._columns.biglist.push({name: 'scheduling', width: '15%', clickable: false});
}

return super.getColumns(view);
}

getName() {
return 'team_route_publishing';
}
}
19 changes: 13 additions & 6 deletions resources/assets/js/custom/inline/team/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ class TeamEdit extends InlineCode {
super.activate();

let self = this;
let code = _inlineManager.getInlineCodeById(this.options.routesTableInlineId);
let tableView = code.getTableView();
tableView.setIsUserModerator(this.options.userIsModerator);

// All dungeon route tables on this page need to know if the user is a moderator or not
let routesTablesInlineCode = _inlineManager.getInlineCode('dungeonroute/table');
for (let index in routesTablesInlineCode) {
let tableView = routesTablesInlineCode[index].getTableView();
tableView.setIsUserModerator(this.options.userIsModerator);
}

let routesTableInlineCode = _inlineManager.getInlineCodeById(this.options.routesTableInlineId);
let tableView = routesTableInlineCode.getTableView();

$('#team_invite_link_copy_to_clipboard').unbind('click').bind('click', function () {
copyToClipboard($('#team_members_invite_link').val());
Expand All @@ -29,7 +36,7 @@ class TeamEdit extends InlineCode {
$('#add_route_btn:enabled').unbind('click').bind('click', function () {
tableView.setAddMode(true);

code.refreshTable();
routesTableInlineCode.refreshTable();
$(this).hide();
$('#view_existing_routes').show();
});
Expand All @@ -38,7 +45,7 @@ class TeamEdit extends InlineCode {
$('#view_existing_routes').unbind('click').bind('click', function () {
tableView.setAddMode(false);

code.refreshTable();
routesTableInlineCode.refreshTable();
$(this).hide();
$('#add_route_btn').show();
});
Expand Down Expand Up @@ -91,7 +98,7 @@ class TeamEdit extends InlineCode {
});
});

$(this.options.routePublishingEnabledSelector).on('change', function(){
$(this.options.routePublishingEnabledSelector).on('change', function () {
$.ajax({
type: 'PUT',
url: `/ajax/team/${self.options.teamPublicKey}/routepublishing`,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<input type="datetime-local" />
15 changes: 8 additions & 7 deletions resources/views/team/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
* @var int $userAdFreeTeamMembersMax
*/
$title = sprintf(__('view_team.edit.title'), $team->name);
$routesTableInlineId = 'team_edit_routes_table';
$title = sprintf(__('view_team.edit.title'), $team->name);
$routesTableInlineId = 'team_edit_routes_table';
$routePublishingTableInlineId = 'team_edit_route_publishing_table';
/** @var User $user */
$user = Auth::user();
Expand Down Expand Up @@ -67,7 +68,7 @@
</a>
@endsection
@include('common.general.inline', ['path' => 'team/edit', 'options' => [
'dependenciesById' => [$routesTableInlineId],
'dependenciesById' => [$routesTableInlineId, $routePublishingTableInlineId],
'routesTableInlineId' => $routesTableInlineId,
'routePublishingEnabledSelector' => '#route_publishing_enabled_checkbox',
Expand Down Expand Up @@ -98,21 +99,21 @@
@include('team.edittabs.routes', [
'inlineId' => $routesTableInlineId,
'team' => $team,
'userIsModerator' => $userIsModerator
'userIsModerator' => $userIsModerator,
])
@include('team.edittabs.members', [
'team' => $team,
'userIsModerator' => $userIsModerator,
'userHasAdFreeTeamMembersPatreonBenefit' => $userHasAdFreeTeamMembersPatreonBenefit,
'userAdFreeTeamMembersRemaining' => $userAdFreeTeamMembersRemaining,
'userAdFreeTeamMembersMax' => $userAdFreeTeamMembersMax
'userAdFreeTeamMembersMax' => $userAdFreeTeamMembersMax,
])
@include('team.edittabs.teamtags', ['team' => $team])

@if($userIsModerator)
@include('team.edittabs.routepublishing', [
'inlineId' => 'team_edit_route_publishing_table',
'team' => $team
'inlineId' => $routePublishingTableInlineId,
'team' => $team,
])
@include('team.edittabs.details', ['team' => $team])
@endif
Expand Down
2 changes: 1 addition & 1 deletion resources/views/team/edittabs/routepublishing.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div class="form-group">
@include('common.dungeonroute.table', [
'inlineId' => $inlineId,
'view' => 'team',
'view' => 'team_route_publishing',
'team' => $team,
'tableId' => 'route_publishing_table',
'filterButtonId' => 'route_publishing_filter_button',
Expand Down

0 comments on commit e15cd17

Please sign in to comment.