Added quick link to create new project from channel page

This commit is contained in:
Gregory Ballantine 2023-03-06 23:44:51 -05:00
parent 4735047682
commit 9b6e38a313
3 changed files with 11 additions and 2 deletions

View File

@ -14,10 +14,17 @@ namespace '/video' do
end
get '/create' do
# check if there's a channel specified
selected_channel = false
if params.has_key?(:channel)
selected_channel = params[:channel].to_i()
end
channels = Channel.all()
erb :'video/create', :locals => {
:title => 'Create new video',
:channels => channels
:channels => channels,
:selected_channel => selected_channel
}
end
post '/create' do

View File

@ -6,6 +6,8 @@
<h4 class="channel-updated">Last updated at: <%= date_format(channel.updated_at) %></h4>
<% end %>
<p><a href="/video/create?channel=<%= channel.id %>">Create video project</a></p>
<p class="channel-description"><%= channel.description %></p>
</div>

View File

@ -24,7 +24,7 @@
<label for="video_channel">Associated channel:</label>
<select class="u-full-width" id="video_channel" name="video_channel" required>
<% channels.each do |c| %>
<option value="<%= c.id %>"><%= c.name %></option>
<option value="<%= c.id %>" <%= 'selected' if c.id == selected_channel %>><%= c.name %></option>
<% end %>
</select>
</div>