-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b8948c
commit 1a52afc
Showing
37 changed files
with
473 additions
and
62 deletions.
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.ss-content { | ||
padding-right: 0.75rem; | ||
background-image: none; | ||
|
||
.ss-list { | ||
height: 150px; | ||
|
||
.ss-option { | ||
color: var(--bs-body-color); | ||
|
||
&:not(.ss-disabled) { | ||
&.ss-selected { | ||
background-color: $primary; | ||
} | ||
|
||
&:first-child { | ||
color: var(--bs-secondary-color); | ||
} | ||
} | ||
|
||
&:hover { | ||
color: var(--bs-body-color); | ||
background-color: $primary; | ||
} | ||
&:first-child { | ||
&.ss-selected { | ||
background-color: $primary-bg-subtle; | ||
} | ||
} | ||
} | ||
} | ||
|
||
.ss-search input:focus { | ||
box-shadow: $box-shadow-sm; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Controller } from '@hotwired/stimulus'; | ||
|
||
// Connects to data-controller="bs-modal" | ||
export default class extends Controller { | ||
connect() { | ||
// eslint-disable-next-line no-undef | ||
this.modal = new bootstrap.Modal(this.element); | ||
|
||
this.modal.show(); | ||
} | ||
|
||
disconnect() { | ||
this.modal.hide(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
app/javascript/controllers/event_form_remove_talk_controller.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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Controller } from '@hotwired/stimulus'; | ||
|
||
// Connects to data-controller="event-form-remove-talk" | ||
export default class extends Controller { | ||
removeRecord(event) { | ||
let talkId = event.currentTarget.dataset.talkId; | ||
let talkPersisted = event.currentTarget.dataset.persisted === 'true'; | ||
let talk = document.getElementById(`talk-${talkId}`); | ||
console.log(talkPersisted); | ||
|
||
if (talkPersisted) { | ||
console.log('to be hidden'); | ||
let removeRecordElement = talk.querySelector('.remove_record'); | ||
removeRecordElement.value = '1'; | ||
talk.className += ' d-none'; | ||
} else { | ||
talk.remove(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Controller } from '@hotwired/stimulus'; | ||
import SlimSelect from 'slim-select'; | ||
|
||
// Connects to data-controller="slim-select" | ||
export default class extends Controller { | ||
connect() { | ||
this.select = new SlimSelect({ | ||
select: this.element, | ||
settings: { | ||
openPosition: 'up', | ||
}, | ||
}); | ||
document.querySelector('svg.ss-arrow').remove(); | ||
} | ||
|
||
disconnect() { | ||
this.select.destroy(); | ||
} | ||
} |
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,36 @@ | ||
import { Controller } from '@hotwired/stimulus'; | ||
import { Turbo } from '@hotwired/turbo-rails'; | ||
// Connects to data-controller="turbo" | ||
export default class extends Controller { | ||
initialize() { | ||
this.element.setAttribute('data-action', 'click->turbo#click'); | ||
} | ||
click(e) { | ||
e.preventDefault(); | ||
|
||
if (this.element.hasAttribute('href')) { | ||
// If href is present, get its value | ||
this.url = this.element.getAttribute('href'); | ||
} else if (this.element.hasAttribute('data-href')) { | ||
// If href is not present, check for data-href attribute | ||
this.url = this.element.getAttribute('data-href'); | ||
} else if (this.element.hasAttribute('formaction')) { | ||
// If href is not present, check for formaction attribute | ||
// breakpoint here | ||
|
||
this.url = this.element.getAttribute('formaction'); | ||
} | ||
if (this.url) { | ||
fetch(this.url, { | ||
headers: { | ||
Accept: 'text/vnd.turbo-stream.html', | ||
}, | ||
}) | ||
.then((r) => r.text()) | ||
.then((html) => Turbo.renderStreamMessage(html)) | ||
.catch((err) => console.log(err)); | ||
} else { | ||
console.log('No URL found'); | ||
} | ||
} | ||
} |
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 @@ | ||
import './update_children_or_append'; |
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,34 @@ | ||
import { StreamActions } from '@hotwired/turbo'; | ||
|
||
StreamActions.update_children_or_append = function () { | ||
function duplicateChildren(existingChildren, newChildrenIds) { | ||
return existingChildren | ||
.filter((existingChild) => newChildrenIds.includes(existingChild.id)) | ||
.map((existingChild) => { | ||
const templateChild = this.templateContent.querySelector(`#${existingChild.id}`); | ||
return { targetChild: existingChild, templateChild }; | ||
}); | ||
} | ||
|
||
if (this.duplicateChildren.length > 0) { | ||
const existingChildren = this.targetElements | ||
.flatMap((e) => [...e.children]) | ||
.filter((c) => !!c.id); | ||
|
||
const newChildrenIds = [...(this.templateContent?.children || [])] | ||
.filter((c) => !!c.id) | ||
.map((c) => c.id); | ||
|
||
const duplicatedChildren = duplicateChildren.call(this, existingChildren, newChildrenIds); | ||
|
||
duplicatedChildren.forEach(({ targetChild, templateChild }) => { | ||
if (targetChild && templateChild) { | ||
const newElement = templateChild.cloneNode(true); | ||
templateChild.remove(); | ||
targetChild.replaceWith(newElement); | ||
} | ||
}); | ||
} else { | ||
this.targetElements.forEach((e) => e.append(this.templateContent)); | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,12 @@ def update? | |
def destroy? | ||
user.admin? | ||
end | ||
|
||
def set_talk? | ||
create? | ||
end | ||
|
||
def generate_talk? | ||
create? | ||
end | ||
end |
Oops, something went wrong.