Add fragment backoffice title and improve validation #22
Conversation
@@ -134,21 +154,26 @@ | |||
e.preventDefault(); | |||
e.stopPropagation(); | |||
|
|||
var sure = confirm("The fragment will be deleted after update. Are you sure?"); | |||
|
|||
if (!sure) { |
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.
This variable is used only once. Why not just write
if (!confirm("The fragment will be deleted after update. Are you sure?")) {
{
}
@@ -134,21 +154,26 @@ | |||
e.preventDefault(); | |||
e.stopPropagation(); | |||
|
|||
var sure = confirm("The fragment will be deleted after update. Are you sure?"); |
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.
No i18n?
7488de3
to
740f0b6
Compare
Hello @sonata-project/contributors, we really need this merge by the morning, can we merge it please ? |
One required check can't be launched but i don't know why |
I'll talk to @soullivaneuh about that |
thanks @greg0ire |
BTW, shouldn't this be split into 2 commits? It looks like you are doing 2 separate things here. |
@soullivaneuh unstuck StyleCI, but you have to force push to trigger it. |
{ | ||
if (empty($object->getBackofficeTitle())) { |
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.
Isn't there a more Symfony-ish way of doing this, by using the NotBlank
constraint?
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.
Could save you some translations…
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.
the whole validation part is still a work in progress, for the moment we can't use symfony constraints, we are working on that on another PR. I will add the todo in doc.
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.
ok
88c53d0
to
834aeee
Compare
834aeee
to
dc1f17e
Compare
@greg0ire I've split it in 3 (to be more precise) |
@@ -42,8 +42,13 @@ public function buildCreateForm(FormMapper $form, FragmentInterface $fragment); | |||
* | |||
* @param FragmentInterface $fragment | |||
* @param ExecutionContextInterface $context | |||
/** |
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.
Uuuh… what?
* @var int | ||
* @var string | ||
*/ | ||
protected $backofficeTitle; |
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.
Should be private
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.
can't set it private, all other properties are protected, and we used them (on fixtures for exemple)
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.
ok leave it as is then
@@ -1,6 +1,6 @@ | |||
{% block form %} | |||
{% set fragmentName = admin.fragmentServices[form.vars.data.type].name %} | |||
<div data-fragment-form="{{ form.vars.id }}" data-form-tmp="true" data-formdata='{ "name": "Fragment {{ fragmentName }}", "type": "{{ fragmentName }}" }' data-errors="{{ form.vars.errors|length }}"> | |||
<div data-fragment-form="{{ form.vars.id }}" data-form-tmp="true" data-formdata='{ "name": "Fragment {{ fragmentName }}", "type": "{{ form.vars.data.backofficeTitle }}" }' data-errors="{{ form.vars.errors|length }}"> |
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.
Linebreak this please
@@ -9,7 +9,7 @@ | |||
</h4> | |||
</div> | |||
<div class="box-body"> | |||
{% if form.vars.errors|length > 0 %} | |||
{% if form.vars.errors is defined and form.vars.errors|length > 0 %} |
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.
form.vars.errors|default([])|lenght
would be shorter, but the best would be to have this variable always defined
Todo | ||
==== | ||
|
||
This bundle is still a work in progress, we need to work more on some part. |
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.
"parts"
dc1f17e
to
927b1ec
Compare
@@ -9,7 +12,7 @@ | |||
</h4> | |||
</div> | |||
<div class="box-body"> | |||
{% if form.vars.errors|length > 0 %} | |||
{% if form.vars.errors|default([])|lenght > 0 %} |
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.
Did you test this? Beware, this is a trick question…
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.
honestly no, i've trust your knowledge :) will do give me 2min :p
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.
Good answer ;) I mispellt length
, and you copied it, that's why I'm asking
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.
@greg0ire all good now :)
927b1ec
to
86e4d85
Compare
@sonata-project/contributors , please review and merge |
86e4d85
to
2f94ba6
Compare
} | ||
|
||
this._elementsIndex++; | ||
console.log('[Sonata.Admin] [fragments|add] current index is ' + this._elementsIndex); |
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.
Admin.log
and not console.log
I mark this PR as |
Changelog
Subject
The goal of this PR is to handle new backoffice title for each fragments. This improve the readability of the admin, instead of seeing only the fragment type, you will see a label related to your content. Also, the validate signature was wrong, because it's called from the article admin.
Before
After