Skip to content

Commit

Permalink
显示 ranking 的人数
Browse files Browse the repository at this point in the history
  • Loading branch information
zw963 committed May 9, 2024
1 parent 6674bf9 commit 0146409
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 16 deletions.
33 changes: 26 additions & 7 deletions src/components/universities/click_edit_td.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,38 @@ class Universities::ClickEditTD < BaseComponent
needs column_name : String
needs column_value : String
needs action : String
needs tooltip : String

def render
td(
"hx-trigger": "click",
"hx-swap": "outerHTML",
"hx-get": action,
"hx-vals": "{
if tooltip.blank?
td(
"hx-trigger": "click",
"hx-swap": "outerHTML",
"hx-get": action,
"hx-vals": "{
\"id\":\"#{id}\",
\"column_name\":\"#{column_name}\",
\"column_value\": \"#{column_value}\"
}",
) do
text column_value
) do
text column_value
end
else
td(
class: "tooltipped",
"data-position": "top",
"data-tooltip": tooltip,
"hx-trigger": "click",
"hx-swap": "outerHTML",
"hx-get": action,
"hx-vals": "{
\"id\":\"#{id}\",
\"column_name\":\"#{column_name}\",
\"column_value\": \"#{column_value}\"
}",
) do
text column_value
end
end
end
end
3 changes: 2 additions & 1 deletion src/pages/universities/htmx/updated_score_input_page.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class Universities::Htmx::UpdatedScoreInputPage < NoLayout
id: id,
column_value: column_value,
column_name: column_name,
action: action
action: action,
tooltip: show_ranking_number(column_value)
)
end
end
24 changes: 16 additions & 8 deletions src/pages/universities/index_page.cr
Original file line number Diff line number Diff line change
Expand Up @@ -238,56 +238,64 @@ class Universities::IndexPage < MainLayout
id: university.id.to_s,
column_value: university.score_2023_min.to_s,
column_name: "score_2023_min",
action: "/htmx/v1/universities/render_update_score_input"
action: "/htmx/v1/universities/render_update_score_input",
tooltip: ""
)
mount(
ClickEditTD,
id: university.id.to_s,
column_value: university.ranking_2023_min.to_s,
column_name: "ranking_2023_min",
action: "/htmx/v1/universities/render_update_score_input"
action: "/htmx/v1/universities/render_update_score_input",
tooltip: show_ranking_number(university.ranking_2023_min)
)
mount(
ClickEditTD,
id: university.id.to_s,
column_value: university.score_2022_min.to_s,
column_name: "score_2022_min",
action: "/htmx/v1/universities/render_update_score_input"
action: "/htmx/v1/universities/render_update_score_input",
tooltip: ""
)
mount(
ClickEditTD,
id: university.id.to_s,
column_value: university.ranking_2022_min.to_s,
column_name: "ranking_2022_min",
action: "/htmx/v1/universities/render_update_score_input"
action: "/htmx/v1/universities/render_update_score_input",
tooltip: show_ranking_number(university.ranking_2022_min)
)
mount(
ClickEditTD,
id: university.id.to_s,
column_value: university.score_2021_min.to_s,
column_name: "score_2021_min",
action: "/htmx/v1/universities/render_update_score_input"
action: "/htmx/v1/universities/render_update_score_input",
tooltip: ""
)
mount(
ClickEditTD,
id: university.id.to_s,
column_value: university.ranking_2021_min.to_s,
column_name: "ranking_2021_min",
action: "/htmx/v1/universities/render_update_score_input"
action: "/htmx/v1/universities/render_update_score_input",
tooltip: show_ranking_number(university.ranking_2021_min)
)
mount(
ClickEditTD,
id: university.id.to_s,
column_value: university.score_2020_min.to_s,
column_name: "score_2020_min",
action: "/htmx/v1/universities/render_update_score_input"
action: "/htmx/v1/universities/render_update_score_input",
tooltip: ""
)
mount(
ClickEditTD,
id: university.id.to_s,
column_value: university.ranking_2020_min.to_s,
column_name: "ranking_2020_min",
action: "/htmx/v1/universities/render_update_score_input"
action: "/htmx/v1/universities/render_update_score_input",
tooltip: show_ranking_number(university.ranking_2022_min)
)
end
end
Expand Down

0 comments on commit 0146409

Please sign in to comment.