This repository has been archived by the owner on Jun 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #694 from omu/improvements
Genel iyileştirmeler
- Loading branch information
Showing
48 changed files
with
235 additions
and
116 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,16 @@ | ||
# frozen_string_literal: true | ||
|
||
class CurriculumDecorator < SimpleDelegator | ||
def openable_courses_for_active_term(appends: nil) | ||
term = AcademicTerm.active.last.try(:term) | ||
|
||
return [] unless term | ||
|
||
courses = semesters.where(term: term) | ||
.includes(:courses) | ||
.where.not(courses: { id: available_courses.pluck(:course_id) }) | ||
.order('courses.name') | ||
.map(&:courses) | ||
[*appends, courses].flatten | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,79 @@ | ||
# frozen_string_literal: true | ||
|
||
module LinkHelper | ||
def link_to_back(path = nil, text = t('action_group.back')) | ||
link_to( | ||
fa_icon('arrow-left', text: text), | ||
path, | ||
class: 'btn btn-secondary btn-sm' | ||
) | ||
end | ||
|
||
def link_to_destroy(path = nil, text = t('action_group.destroy')) | ||
link_to( | ||
fa_icon('trash', text: text), | ||
path, | ||
method: :delete, | ||
data: { confirm: t('are_you_sure') }, | ||
class: 'btn btn-outline-danger btn-sm' | ||
) | ||
end | ||
|
||
def link_to_edit(path = nil, text = t('action_group.edit')) | ||
link_to( | ||
fa_icon('pencil', text: text), | ||
path, | ||
class: 'btn btn-outline-success btn-sm' | ||
) | ||
end | ||
LINKS = { | ||
back: { | ||
icon: 'arrow-left', | ||
text: I18n.t('action_group.back'), | ||
options: { | ||
class: 'btn btn-secondary btn-sm' | ||
} | ||
}, | ||
destroy: { | ||
icon: 'trash', | ||
text: I18n.t('action_group.destroy'), | ||
options: { | ||
class: 'btn btn-outline-danger btn-sm', | ||
method: :delete, | ||
data: { confirm: I18n.t('are_you_sure') } | ||
} | ||
}, | ||
edit: { | ||
icon: 'pencil', | ||
text: I18n.t('action_group.edit'), | ||
options: { | ||
class: 'btn btn-outline-success btn-sm' | ||
} | ||
}, | ||
new: { | ||
icon: 'plus', | ||
text: I18n.t('action_group.add'), | ||
options: { | ||
class: 'btn btn-outline-primary btn-sm', | ||
id: 'add-button' | ||
} | ||
}, | ||
show: { | ||
icon: 'eye', | ||
text: I18n.t('action_group.show'), | ||
options: { | ||
class: 'btn btn-outline-info btn-sm' | ||
} | ||
}, | ||
update: { | ||
icon: 'pencil-square-o', | ||
text: I18n.t('action_group.update'), | ||
options: { | ||
class: 'btn btn-outline-info btn-sm' | ||
} | ||
}, | ||
file: { | ||
icon: 'file-word-o', | ||
text: I18n.t('action_group.file'), | ||
options: { | ||
class: 'btn btn-secondary btn-sm' | ||
} | ||
} | ||
}.freeze | ||
|
||
def link_to_new(path = nil, text = t('action_group.add')) | ||
link_to( | ||
fa_icon('plus', text: text), | ||
path, | ||
class: 'btn btn-outline-primary btn-sm', | ||
id: 'add-button' | ||
) | ||
LINKS.each do |action, configuration| | ||
define_method("link_to_#{action}") do |*args| | ||
link_builder(args, configuration) | ||
end | ||
end | ||
|
||
def link_to_show(path = nil, text = t('action_group.show')) | ||
link_to( | ||
fa_icon('eye', text: text), | ||
path, | ||
class: 'btn btn-outline-info btn-sm' | ||
) | ||
end | ||
private | ||
|
||
def link_to_update(path = nil, text = t('action_group.update')) | ||
def link_builder(args, configuration) | ||
text, path = split_args_for_link_to(args) | ||
link_to( | ||
fa_icon('pencil-square-o', text: text), | ||
fa_icon(configuration[:icon], text: text || configuration[:text]), | ||
path, | ||
class: 'btn btn-outline-info btn-sm' | ||
configuration.fetch(:options, {}) | ||
) | ||
end | ||
|
||
def link_to_file(path = nil, text = t('action_group.file')) | ||
link_to( | ||
fa_icon('file-word-o', text: text), | ||
path, | ||
class: 'btn btn-secondary btn-sm' | ||
) | ||
def split_args_for_link_to(args) | ||
args.length == 1 ? [nil, *args] : args | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class AcademicTermValidator < ActiveModel::Validator | ||
def validate(record) | ||
return if record.active? | ||
return if AcademicTerm.where.not(id: record.id).exists?(active: true) | ||
|
||
record.errors[:active] << I18n.t('active_check', scope: %i[validators academic_term]) | ||
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
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
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
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.