system de tag sur les icones (ref #190)

This commit is contained in:
afornerot 2020-07-17 16:06:18 +02:00
parent 6db9222fc4
commit 57a5517e19
4 changed files with 84 additions and 3 deletions

View File

@ -27,6 +27,11 @@ class Icon
*/ */
private $label; private $label;
/**
* @ORM\Column(type="string", length=250, nullable=true)
*/
private $tags;
/** /**
* @ORM\ManyToOne(targetEntity="Cadoles\CoreBundle\Entity\User", inversedBy="icons") * @ORM\ManyToOne(targetEntity="Cadoles\CoreBundle\Entity\User", inversedBy="icons")
* @ORM\JoinColumn(nullable=true) * @ORM\JoinColumn(nullable=true)
@ -398,4 +403,28 @@ class Icon
{ {
return $this->groups; return $this->groups;
} }
/**
* Set tags
*
* @param string $tags
*
* @return Icon
*/
public function setTags($tags)
{
$this->tags = $tags;
return $this;
}
/**
* Get tags
*
* @return string
*/
public function getTags()
{
return $this->tags;
}
} }

View File

@ -34,6 +34,11 @@ class IconType extends AbstractType
"disabled" => ($options["mode"]=="delete"?true:false) "disabled" => ($options["mode"]=="delete"?true:false)
) )
); );
$builder->add('tags', TextType::class, [
'label' => 'Tags',
'required' => false
]);
} }
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)

View File

@ -57,6 +57,9 @@
<div style="width:200px; margin: 10px auto;text-align:center;"> <div style="width:200px; margin: 10px auto;text-align:center;">
Privilégiez des images carrées de minimum 90px par 90px et avec un fond transparent Privilégiez des images carrées de minimum 90px par 90px et avec un fond transparent
</div> </div>
{{ form_row(form.tags) }}
</div> </div>
</div> </div>
{{ form_end(form) }} {{ form_end(form) }}

View File

@ -2,6 +2,8 @@
{% block pagewrapper %} {% block pagewrapper %}
<div class="row"> <div class="row">
<div class="col-md-12" style="margin-bottom:15px"> <div class="col-md-12" style="margin-bottom:15px">
<a onclick="window.parent.$('#mymodal').modal('hide');" class="btn btn-default">Fermer</a> <a onclick="window.parent.$('#mymodal').modal('hide');" class="btn btn-default">Fermer</a>
{% if access=="user" %} {% if access=="user" %}
@ -12,19 +14,61 @@
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
<label class="control-label" for="group_label">Recherche</label>
<input type="text" id="icon_search" name="icon_search" class="form-control form-control" style="margin-bottom:15px">
{% if iconsuser is not empty %} {% if iconsuser is not empty %}
<h3>Mes Icônes</h3> <h3>Mes Icônes</h3>
{% for icon in iconsuser %} {% for icon in iconsuser %}
<img onClick="window.parent.selIcon({{ icon.id }},'{{icon.label}}')" id="icon-{{ icon.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ icon.label }}" style="cursor:pointer; padding:2px; margin-bottom:2px; background-color: #{{ color["main"]}}"> {% set tag = "" %}
{% if icon.tags %}
{% set tag = icon.tags %}
{% endif %}
{% if icon.label starts with 'uploads/icon/icon_' %}
{% set tag = tag ~ icon.label|replace({'uploads/icon/icon_':'', '.png':''}) %}
{% endif %}
<img onClick="window.parent.selIcon({{ icon.id }},'{{icon.label}}')" data="{{tag}}" id="icon-{{ icon.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ icon.label }}" style="cursor:pointer; padding:2px; margin-bottom:2px; background-color: #{{ color["main"]}}">
{% endfor %} {% endfor %}
<h3>Icônes Communs</h3> <h3>Icônes Communs</h3>
{% endif %} {% endif %}
{% for icon in icons %} {% for icon in icons %}
<img onClick="window.parent.selIcon({{ icon.id }},'{{icon.label}}')" id="icon-{{ icon.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ icon.label }}" style="cursor:pointer; padding:2px; margin-bottom:2px; background-color: #{{ color["main"]}}"> {% set tag = "" %}
{% if icon.tags %}
{% set tag = icon.tags %}
{% endif %}
{% if icon.label starts with 'uploads/icon/icon_' %}
{% set tag = tag ~ icon.label|replace({'uploads/icon/icon_':'', '.png':''}) %}
{% endif %}
<img onClick="window.parent.selIcon({{ icon.id }},'{{icon.label}}')" data="{{tag}}" id="icon-{{ icon.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ icon.label }}" style="cursor:pointer; padding:2px; margin-bottom:2px; background-color: #{{ color["main"]}}">
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
{% block localjavascript %}
$('document').ready(function(){
$( "#icon_search" ).focus();
});
$( "#icon_search" ).on("keyup", function() {
if($( "#icon_search" ).val()=="")
$(".grid-item-img").show();
else {
tags=$( "#icon_search" ).val().toLowerCase().split(' ');
$(".grid-item-img").hide();
tags.forEach(function(tag){
$(".grid-item-img").each(function(index) {
icontags=$( this ).attr("data");
if (typeof icontags !== 'undefined') {
if(icontags.includes(tag)) $(this).show();
}
});
});
}
});
{% endblock %}