-
-
Notifications
You must be signed in to change notification settings - Fork 396
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
Add available services to meetings #3150
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9449512
Add meeting services to admin form
rbngzlv 158fce6
Add meeting services to seeds
rbngzlv e41c813
Public view markup
rbngzlv 2ab4d51
Remove duplicated javascript components (available in admin component)
rbngzlv b19cbea
Add specs
rbngzlv 837c850
Copy services when duplicating a meeting
rbngzlv 54a239b
Add change log entry
rbngzlv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -413,6 +413,10 @@ $datetime-bg: $primary; | |
display: none; | ||
fill: $anchor-color; | ||
|
||
&.alert{ | ||
fill: $alert; | ||
} | ||
|
||
@include breakpoint(medium){ | ||
margin-right: 1rem; | ||
display: block; | ||
|
@@ -440,6 +444,10 @@ $datetime-bg: $primary; | |
} | ||
} | ||
|
||
.card--list__text--top{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this property-modified always comes along with .card--list__text {
...
// other properties
&.card--list__item--top{
// your properties
}
} |
||
align-items: start; | ||
} | ||
|
||
.card--list__heading{ | ||
margin-bottom: 0; | ||
display: block; | ||
|
1 change: 1 addition & 0 deletions
1
decidim-meetings/app/assets/config/admin/decidim_meetings_manifest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
//= link decidim/meetings/admin/meetings_form.js | ||
//= link decidim/meetings/admin/registrations_form.js |
78 changes: 78 additions & 0 deletions
78
decidim-meetings/app/assets/javascripts/decidim/meetings/admin/meetings_form.js.es6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
((exports) => { | ||
const { AutoLabelByPositionComponent, AutoButtonsByPositionComponent, createDynamicFields, createSortList } = exports.DecidimAdmin; | ||
|
||
const wrapperSelector = ".meeting-services"; | ||
const fieldSelector = ".meeting-service"; | ||
|
||
const autoLabelByPosition = new AutoLabelByPositionComponent({ | ||
listSelector: ".meeting-service:not(.hidden)", | ||
labelSelector: ".card-title span:first", | ||
onPositionComputed: (el, idx) => { | ||
$(el).find("input[name$=\\[position\\]]").val(idx); | ||
} | ||
}); | ||
|
||
const autoButtonsByPosition = new AutoButtonsByPositionComponent({ | ||
listSelector: ".meeting-service:not(.hidden)", | ||
hideOnFirstSelector: ".move-up-service", | ||
hideOnLastSelector: ".move-down-service" | ||
}); | ||
|
||
const createSortableList = () => { | ||
createSortList(".meeting-services-list:not(.published)", { | ||
handle: ".service-divider", | ||
placeholder: '<div style="border-style: dashed; border-color: #000"></div>', | ||
forcePlaceholderSize: true, | ||
onSortUpdate: () => { autoLabelByPosition.run() } | ||
}); | ||
}; | ||
|
||
const hideDeletedService = ($target) => { | ||
const inputDeleted = $target.find("input[name$=\\[deleted\\]]").val(); | ||
|
||
if (inputDeleted === "true") { | ||
$target.addClass("hidden"); | ||
$target.hide(); | ||
} | ||
}; | ||
|
||
createDynamicFields({ | ||
placeholderId: "meeting-service-id", | ||
wrapperSelector: wrapperSelector, | ||
containerSelector: ".meeting-services-list", | ||
fieldSelector: fieldSelector, | ||
addFieldButtonSelector: ".add-service", | ||
removeFieldButtonSelector: ".remove-service", | ||
moveUpFieldButtonSelector: ".move-up-service", | ||
moveDownFieldButtonSelector: ".move-down-service", | ||
onAddField: () => { | ||
createSortableList(); | ||
|
||
autoLabelByPosition.run(); | ||
autoButtonsByPosition.run(); | ||
}, | ||
onRemoveField: () => { | ||
autoLabelByPosition.run(); | ||
autoButtonsByPosition.run(); | ||
}, | ||
onMoveUpField: () => { | ||
autoLabelByPosition.run(); | ||
autoButtonsByPosition.run(); | ||
}, | ||
onMoveDownField: () => { | ||
autoLabelByPosition.run(); | ||
autoButtonsByPosition.run(); | ||
} | ||
}); | ||
|
||
createSortableList(); | ||
|
||
$(fieldSelector).each((idx, el) => { | ||
const $target = $(el); | ||
|
||
hideDeletedService($target); | ||
}); | ||
|
||
autoLabelByPosition.run(); | ||
autoButtonsByPosition.run(); | ||
})(window); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
decidim-meetings/app/forms/decidim/meetings/admin/meeting_service_form.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Meetings | ||
module Admin | ||
# This class holds a Form to update meeting services | ||
class MeetingServiceForm < Decidim::Form | ||
include TranslatableAttributes | ||
|
||
attribute :deleted, Boolean, default: false | ||
|
||
translatable_attribute :title, String | ||
translatable_attribute :description, String | ||
|
||
validates :title, translatable_presence: true, unless: :deleted | ||
|
||
def to_param | ||
id || "meeting-service-id" | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
decidim-meetings/app/views/decidim/meetings/admin/meetings/_service.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<% service = form.object %> | ||
|
||
<div class="card meeting-service" id="<%= id %>-field"> | ||
<div class="card-divider service-divider"> | ||
<h2 class="card-title"> | ||
<span><%= t(".service") %></span> | ||
|
||
<button class="button small alert hollow move-up-service button--title"> | ||
<%== "#{icon("arrow-top")} #{t(".up")}" %> | ||
</button> | ||
|
||
<button class="button small alert hollow move-down-service button--title"> | ||
<%== "#{icon("arrow-bottom")} #{t(".down")}" %> | ||
</button> | ||
|
||
<button class="button small alert hollow remove-service button--title"> | ||
<%= t(".remove") %> | ||
</button> | ||
</h2> | ||
</div> | ||
|
||
<div class="card-section"> | ||
<div class="row column"> | ||
<%= | ||
form.translated( | ||
:text_field, | ||
:title, | ||
tabs_id: id, | ||
label: t(".title") | ||
) | ||
%> | ||
</div> | ||
|
||
<div class="row column"> | ||
<%= | ||
form.translated( | ||
:text_area, | ||
:description, | ||
rows: 2, | ||
tabs_id: id, | ||
label: t(".description") | ||
) | ||
%> | ||
</div> | ||
</div> | ||
|
||
<%= form.hidden_field :deleted, value: false %> | ||
</div> |
25 changes: 25 additions & 0 deletions
25
decidim-meetings/app/views/decidim/meetings/admin/meetings/_services.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<div class="card"> | ||
<div class="card-divider"> | ||
<h2 class="card-title"><%= t(".services") %></h2> | ||
</div> | ||
|
||
<div class="card-section"> | ||
<div class="meeting-services"> | ||
<template> | ||
<%= fields_for "meeting[services][#{blank_service.to_param}]", blank_service do |service_form| %> | ||
<%= render "decidim/meetings/admin/meetings/service", form: service_form, id: tabs_id_for_service(blank_service) %> | ||
<% end %> | ||
</template> | ||
|
||
<div class="meeting-services-list"> | ||
<% form.object.services.each do |service| %> | ||
<%= fields_for "meeting[services][]", service do |service_form| %> | ||
<%= render "decidim/meetings/admin/meetings/service", form: service_form, id: tabs_id_for_service(service) %> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
|
||
<button class="button add-service"><%= t(".add_service") %></button> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There's a mixin called
modifiers
, that you might use to wrap all possibilities (even they're not in use).Instead of this block, switch it by
@include modifiers(fill);
. Now, no matter which status you assign to the parent element, the propertyfill
will change accordinglyThere 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.
Extra tip: I miss
$anchor-color
is a custom color status, so in that case....@include modifiers(fill, (alert: $anchor-color))
. Now I see again, it's not a big deal, but it's a way to handle statuses in the same way. You'll find other examples in the same file