Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ministerstvo spravedlnosti
Azahara schema
Commits
d5cb8c4b
Commit
d5cb8c4b
authored
Sep 19, 2018
by
Ondřej Ezr
Browse files
formatter is actually a presenter
parent
3135fd74
Pipeline
#13
failed with stage
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/helpers/azahara_schema/application_helper.rb
View file @
d5cb8c4b
...
...
@@ -69,11 +69,11 @@ module AzaharaSchema
end
def
azahara_attribute_for
(
model
,
name
)
AzaharaSchema
::
Schema
.
schema_class_for
(
model
).
attribute
(
model
,
name
)
::
AzaharaSchema
::
Schema
.
schema_class_for
(
model
).
attribute
(
model
,
name
)
end
def
attribute_formatter_for
(
schema_or_model
,
**
options
)
AttributeFormat
ter
.
formatter_for
(
schema_or_model
).
new
(
schema_or_model
,
self
,
options
)
::
AzaharaSchema
::
Presen
ter
.
formatter_for
(
schema_or_model
).
new
(
schema_or_model
,
self
,
options
)
end
def
unfilled_attribute_message
...
...
app/views/azahara_schema/_schema.html.erb
View file @
d5cb8c4b
...
...
@@ -2,6 +2,8 @@
create_attributes
||=
{}
create_model
||=
schema
.
model
create_model
=
create_model
.
new
create_scope
||=
[]
create_scope
=
create_scope
.
dup
.
push
(
create_model
)
%>
<%
if
local_assigns
.
fetch
(
:filters
,
true
)
%>
...
...
@@ -11,7 +13,7 @@
<div
class=
"btn-toolbar text-right"
role=
"toolbar"
aria-label=
"Toolbar"
>
<%
if
can?
(
:create
,
create_model
)
%>
<div
class=
"btn-group"
role=
"group"
aria-label=
"
<%=
t
(
'label_actions'
)
%>
"
>
<%=
link_to
label_record_action
(
create_model
),
new_polymorphic_path
(
create_
model
,
create_attributes
),
class:
'btn btn-primary'
%>
<%=
link_to
label_record_action
(
create_model
),
new_polymorphic_path
(
create_
scope
,
create_attributes
),
class:
'btn btn-primary'
%>
</div>
<%
end
%>
</div>
...
...
lib/azahara_schema.rb
View file @
d5cb8c4b
...
...
@@ -8,7 +8,7 @@ require 'azahara_schema/outputs'
require
'azahara_schema/output'
require
'azahara_schema/schema'
require
'azahara_schema/model_schema'
require
'azahara_schema/
attribute_format
ter'
require
'azahara_schema/
presen
ter'
if
Object
.
const_defined?
(
'Rails'
)
require
"azahara_schema/engine"
...
...
lib/azahara_schema/
attribute_format
ter.rb
→
lib/azahara_schema/
presen
ter.rb
View file @
d5cb8c4b
module
AzaharaSchema
class
AttributeFormat
ter
class
Presen
ter
def
self
.
default_formatter
=
(
formatter_klass
)
@default_formatter
=
formatter_klass
end
def
self
.
default_formatter
@default_formatter
||
AzaharaSchema
::
AttributeFormat
ter
@default_formatter
||
AzaharaSchema
::
Presen
ter
end
def
self
.
formatter_for
(
schema_or_entity
)
...
...
@@ -19,7 +19,7 @@ module AzaharaSchema
klasses
<<
klass
end
klasses
.
each
do
|
kls
|
schema_klass
=
"
#{
kls
.
name
}
Format
ter"
.
safe_constantize
||
"
Format
ters::
#{
kls
.
name
}
Format
ter"
.
safe_constantize
schema_klass
=
"
#{
kls
.
name
}
Presen
ter"
.
safe_constantize
||
"
Presen
ters::
#{
kls
.
name
}
Presen
ter"
.
safe_constantize
return
schema_klass
if
schema_klass
end
default_formatter
...
...
lib/azahara_schema/version.rb
View file @
d5cb8c4b
module
AzaharaSchema
VERSION
=
'0.3.1
7
'
VERSION
=
'0.3.1
8
'
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment