Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
Merge branch dev-#1698 of https://github.com/morishita1222/basercms fix
Browse files Browse the repository at this point in the history
… #2216
  • Loading branch information
ゴンドー committed Apr 4, 2023
1 parent 1a64b2d commit d0a23ad
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 2 deletions.
Expand Up @@ -249,6 +249,19 @@ class="col-head bca-form-table__label"><?php echo $this->BcAdminForm->label('opt
<?php echo $this->BcAdminForm->error('options') ?>
</td>
</tr>
<tr id="RowAutoComplete">
<th class="col-head bca-form-table__label"><?php echo $this->BcForm->label('autocomplete', __d('baser', 'オートコンプリート')) ?></th>
<td class="col-input bca-form-table__input">
<?php echo $this->BcAdminForm->control('autocomplete', ['type' => 'select', 'options' => $autoCompleteOptions]) ?>
<?php echo $this->BcAdminForm->error('autocomplete') ?>
<i class="bca-icon--question-circle bca-help"></i>
<div class="bca-helptext">
<ul>
<li><?php echo __d('baser_core', 'オートコンプリート属性については<a href="https://developer.mozilla.org/ja/docs/Web/HTML/Attributes/autocomplete" target="_blank">リファレンス</a>を参照してください。') ?></li>
</ul>
</div>
</td>
</tr>
<tr id="RowClass">
<th
class="col-head bca-form-table__label"><?php echo $this->BcAdminForm->label('class', __d('baser_core', 'クラス名')) ?></th>
Expand Down
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);

use BaserCore\Database\Migration\BcMigration;

class AddAutoCompleteMailFields extends BcMigration
{
/**
* Up Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-up-method
* @return void
*/
public function up()
{
$this->table('mail_fields')
->addColumn('autocomplete', 'string', [
'after' => 'options',
'default' => null,
'null' => true,
])
->update();
}

/**
* Down Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-down-method
* @return void
*/
public function down()
{
$this->table('mail_fields')
->removeColumn('autocomplete')
->update();
}
}
69 changes: 69 additions & 0 deletions plugins/bc-mail/config/setting.php
Expand Up @@ -84,5 +84,74 @@
'BcMail' => [
'Mail.getForm'
]
],
'BcMail' => [
'autoComplete' => [
['name' => 'none', 'title' => '指定しない'],
['name' => 'off', 'title' => '無効'],
['name' => 'name', 'title' => '名前', 'child' => [
['name' => 'honorific-prefix', 'title' => '接頭語(Mr.,Mrs.等)'],
['name' => 'given-name', 'title' => '名前'],
['name' => 'additional-name', 'title' => 'ミドルネーム'],
['name' => 'family-name', 'title' => '名字'],
['name' => 'honorific-suffix', 'title' => '接尾語(Jr.等)'],
]],
['name' => 'nickname', 'title' => 'ニックネーム'],
['name' => 'organization-title', 'title' => '役職'],
['name' => 'username', 'title' => 'ユーザー名'],
['name' => 'new-password', 'title' => '新しいパスワード'],
['name' => 'current-password', 'title' => '現在のパスワード'],
['name' => 'one-time-code', 'title' => 'ワンタイムコード'],
['name' => 'organization', 'title' => '企業または団体の名前'],
['name' => 'street-address', 'title' => '住所', 'child' => [
['name' => 'street-address1', 'title' => '住所(1行目)'],
['name' => 'street-address2', 'title' => '住所(2行目)'],
['name' => 'street-address3', 'title' => '住所(3行目)'],
]],
['name' => 'address-level1', 'title' => '住所1(都道府県、州)'],
['name' => 'address-level2', 'title' => '住所2(市町村)'],
['name' => 'address-level3', 'title' => '住所3(3番目の行政レベル)'],
['name' => 'address-level4', 'title' => '住所4(もっとも細かい行政レベル)'],
['name' => 'country', 'title' => '国コード'],
['name' => 'country-name', 'title' => '国名'],
['name' => 'postal-code', 'title' => '郵便番号'],
['name' => 'cc-name', 'title' => 'クレジットカード名義', 'child' => [
['name' => 'cc-given-name', 'title' => 'クレジットカード名義(名前)'],
['name' => 'cc-additional-name', 'title' => 'クレジットカード名義(ミドルネーム)'],
['name' => 'cc-family-name', 'title' => 'クレジットカード名義(名字)'],
]],
['name' => 'cc-number', 'title' => 'クレジットカード番号'],
['name' => 'cc-exp', 'title' => 'クレジットカード有効期限', 'child' => [
['name' => 'cc-exp-month', 'title' => 'クレジットカード有効期限(月)'],
['name' => 'cc-exp-year', 'title' => 'クレジットカード有効期限(年)'],
]],
['name' => 'cc-csc', 'title' => 'クレジットカードセキュリティコード'],
['name' => 'cc-type', 'title' => 'クレジットカード種類'],
['name' => 'transaction-currency', 'title' => '決済通貨'],
['name' => 'transaction-amount', 'title' => '決済通貨の単位による量'],
['name' => 'language', 'title' => '言語'],
['name' => 'bday', 'title' => '生年月日', 'child' => [
['name' => 'bday-day', 'title' => '生年月日(日)'],
['name' => 'bday-month', 'title' => '生年月日(月)'],
['name' => 'bday-year', 'title' => '生年月日(年)'],
]],
['name' => 'sex', 'title' => '性別'],
['name' => 'url', 'title' => 'URL'],
['name' => 'photo', 'title' => '画像'],
['name' => 'tel', 'title' => '電話番号', 'child' => [
['name' => 'tel-country-code', 'title' => '国番号'],
['name' => 'tel-national', 'title' => '国際電話番号', 'child' => [
['name' => 'tel-area-code', 'title' => '電話番号(市外局番)'],
['name' => 'tel-local', 'title' => '国番号や市外局番を含まない電話番号', 'child' => [
['name' => 'tel-local-prefix', 'title' => '電話番号(市内局番)'],
['name' => 'tel-local-suffix', 'title' => '電話番号(加入者番号)'],
]],
]],
]],
['name' => 'tel-extension', 'title' => '内線番号'],
['name' => 'email', 'title' => 'Eメールアドレス'],
['name' => 'impp', 'title' => 'インスタントメッセージングプロトコルの端点'],
['name' => 'on', 'title' => '自動設定'],
]
]
];
6 changes: 4 additions & 2 deletions plugins/bc-mail/src/Service/Admin/MailFieldsAdminService.php
Expand Up @@ -70,7 +70,8 @@ public function getViewVarsForAdd(int $mailContentId, EntityInterface $mailField
return [
'mailContent' => $mailContent,
'mailField' => $mailField,
'publishLink' => $this->getPublishLink($mailContent)
'publishLink' => $this->getPublishLink($mailContent),
'autoCompleteOptions' => $this->getAutoCompleteOptions(),
];
}

Expand All @@ -91,7 +92,8 @@ public function getViewVarsForEdit(int $mailContentId, EntityInterface $mailFiel
return [
'mailContent' => $mailContent,
'mailField' => $mailField,
'publishLink' => $this->getPublishLink($mailContent)
'publishLink' => $this->getPublishLink($mailContent),
'autoCompleteOptions' => $this->getAutoCompleteOptions(),
];
}

Expand Down
35 changes: 35 additions & 0 deletions plugins/bc-mail/src/Service/MailFieldsService.php
Expand Up @@ -18,6 +18,7 @@
use BaserCore\Utility\BcContainerTrait;
use BcMail\Model\Entity\MailField;
use BcMail\Model\Table\MailFieldsTable;
use Cake\Core\Configure;
use Cake\Datasource\EntityInterface;
use Cake\ORM\TableRegistry;
use Throwable;
Expand Down Expand Up @@ -320,4 +321,38 @@ public function changeSort(int $id, int $offset, array $conditions = []): bool
return $result;
}

/**
* オートコンプリートオプションを取得する
*
* @return array
* @checked
* @noTodo
*/
public function getAutoCompleteOptions(): array
{
$autoCompleteDatas = Configure::read('BcMail.autoComplete');

$autoCompleteOptions = [];
foreach ($autoCompleteDatas as $data) {
$autoCompleteOptions[$data['name']] = $data['title'];
if (isset($data['child'])) {
foreach ($data['child'] as $dataChild1) {
$autoCompleteOptions[$dataChild1['name']] = ' └' . $dataChild1['title'];
if (isset($dataChild1['child'])) {
foreach ($dataChild1['child'] as $dataChild2) {
$autoCompleteOptions[$dataChild2['name']] = '  └' . $dataChild2['title'];
if (isset($dataChild2['child'])) {
foreach ($dataChild2['child'] as $dataChild3) {
$autoCompleteOptions[$dataChild3['name']] = '   └' . $dataChild3['title'];
}
}
}
}
}
}
}

return $autoCompleteOptions;
}

}
3 changes: 3 additions & 0 deletions plugins/bc-mail/src/View/Helper/MailfieldHelper.php
Expand Up @@ -42,6 +42,9 @@ public function getAttributes($data)
$attributes['rows'] = $data['text_rows'];
$attributes['maxlength'] = $data['maxlength'];
$attributes['class'] = $data['class'];
if ($data['autocomplete'] !== 'none') {
$attributes['autocomplete'] = $data['autocomplete'];
}
if ($data['type'] === 'multi_check') {
$attributes['multiple'] = true;
} elseif ($data['type'] === 'tel') {
Expand Down

0 comments on commit d0a23ad

Please sign in to comment.