Skip to content

Commit

Permalink
Changes requested
Browse files Browse the repository at this point in the history
  • Loading branch information
JaviviJR committed Sep 16, 2024
1 parent 30cd350 commit ffbdc54
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 38 deletions.
8 changes: 4 additions & 4 deletions assets/controllers/form-related-links_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default class extends Controller {
static values = {
index: Number,
label: String,
link: String,
value: String,
deleteIcon: String,
};

Expand All @@ -29,11 +29,11 @@ export default class extends Controller {
));
rowNode.appendChild(nodeLabel);

const nodeLink = this.#htmlToNode(this.linkValue.replace(
const nodeValue = this.#htmlToNode(this.valueValue.replace(
/__name__/g,
this.indexValue,
));
rowNode.appendChild(nodeLink);
rowNode.appendChild(nodeValue);

this.#addButtonDeleteLink(rowNode);

Expand All @@ -44,7 +44,7 @@ export default class extends Controller {
#addButtonDeleteLink(item) {
const removeFormButton = document.createElement('button');
removeFormButton.innerHTML = this.deleteIconValue;
removeFormButton.className = 'btn';
removeFormButton.className = 'btn btn__secondary';

item.append(removeFormButton);

Expand Down
9 changes: 0 additions & 9 deletions assets/styles/layout/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,3 @@ div.input-box {
margin-bottom: 0;
flex-grow: 1
}

.related-link-row button {
padding: 0;
background: none;
font-size: 1.5rem;
border: 0;
color: var(--kbin-input-text-color);

}
1 change: 0 additions & 1 deletion src/Controller/User/Profile/UserEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace App\Controller\User\Profile;

use App\Controller\AbstractController;
use App\DTO\RelatedLinkDTO;
use App\DTO\UserDto;
use App\Form\UserBasicType;
use App\Form\UserEmailType;
Expand Down
24 changes: 12 additions & 12 deletions src/DTO/RelatedLinkDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
class RelatedLinkDTO
{
private string $label;
private string $link;
private bool $verified = false;
private string $value;
private bool $verifiedLink = false;

/**
* @return string
Expand All @@ -27,32 +27,32 @@ public function setLabel(string $label): void
/**
* @return string
*/
public function getLink(): string
public function getValue(): string
{
return $this->link;
return $this->value;
}

/**
* @param string $link
* @param string $value
*/
public function setLink(string $link): void
public function setValue(string $value): void
{
$this->link = $link;
$this->value = $value;
}

/**
* @return bool
*/
public function isVerified(): bool
public function isVerifiedLink(): bool
{
return $this->verified;
return $this->verifiedLink;
}

/**
* @param bool $verified
* @param bool $verifiedLink
*/
public function setVerified(bool $verified): void
public function setVerifiedLink(bool $verifiedLink): void
{
$this->verified = $verified;
$this->verifiedLink = $verifiedLink;
}
}
5 changes: 0 additions & 5 deletions src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,4 @@ public function getRelatedLinks(): array
{
return $this->relatedLinks;
}

public function setRelatedLinks(array $relatedLinks): void
{
$this->relatedLinks = $relatedLinks;
}
}
2 changes: 0 additions & 2 deletions src/Factory/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public function __construct(

public function createDto(User $user): UserDto
{
// $temp = $this->denormalizer->denormalize($user->getRelatedLinks(), sprintf('%s[]', RelatedLinkDTO::class));

$dto = UserDto::create(
$user->username,
$user->email,
Expand Down
6 changes: 3 additions & 3 deletions src/Form/UserRelatedDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('label', TextType::class)
->add('link', UrlType::class)
->add('value', UrlType::class)
->setDataMapper($this);
;
}
Expand All @@ -40,7 +40,7 @@ public function mapDataToForms($viewData, \Traversable $forms): void
$forms = iterator_to_array($forms);

$forms['label']->setData($viewData->getLabel());
$forms['link']->setData($viewData->getLink());
$forms['value']->setData($viewData->getValue());
}

public function mapFormsToData(\Traversable $forms, &$viewData): void
Expand All @@ -53,7 +53,7 @@ public function mapFormsToData(\Traversable $forms, &$viewData): void
// beware of type inconsistency, see caution below
$viewData = new RelatedLinkDTO();
$viewData->setLabel($forms['label']->getData());
$viewData->setLink($forms['link']->getData());
$viewData->setValue($forms['value']->getData());
}

public function configureOptions(OptionsResolver $resolver): void
Expand Down
4 changes: 2 additions & 2 deletions templates/user/settings/profile.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
{{ stimulus_controller('form-related-links') }}
data-form-related-links-index-value="{{ form.relatedLinks|length }}"
data-form-related-links-link-value="{{
form_row(form.relatedLinks.vars.prototype.link, {
form_row(form.relatedLinks.vars.prototype.value, {
label: false
})|e('html_attr')
}}"
Expand All @@ -70,7 +70,7 @@
{{ form_row(item_form.label, {
label: false
}) }}
{{ form_row(item_form.link, {
{{ form_row(item_form.value, {
label: false
}) }}
</div>
Expand Down

0 comments on commit ffbdc54

Please sign in to comment.