Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

定休日カレンダー機能を実装 #4974

Merged
merged 37 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d154543
管理画面コンテンツ作成開始
Feb 15, 2021
d90544c
定休日新規登録処理実装
Feb 17, 2021
9688c91
更新・削除処理まで実装
Feb 17, 2021
3cfa0f3
フロント側処理実装中
Feb 22, 2021
4006a9c
Carbonでカレンダーデータ作成中
Mar 9, 2021
e9c0405
カレンダー取得処理など追加
Mar 10, 2021
aa6b8a1
2ヶ月分のカレンダー配列作成と前後の空白埋めを実装
Mar 12, 2021
c4a8e79
定休日マッチング実装中
Mar 12, 2021
bb3181b
定休日フラグ設定まではなんとかできた
Mar 15, 2021
28f69f2
カレンダーのスタイル以外は実装完了
Mar 15, 2021
e1183e7
重複チェック実装もれ発見。一旦コメントに記載。
Mar 15, 2021
a69a649
休業日文言追加と今日を強調するフラグ追加と表示対応
Mar 16, 2021
fff7dc4
定休日登録の重複チェックを実装
Mar 16, 2021
5a9aae8
不要コメントと不要useを削除
Mar 16, 2021
5715867
メッセージファイル修正
Mar 16, 2021
8c51ed1
dtb_blockのcsvデータを追加
Mar 16, 2021
b3f9345
Migrationファイルを追加
Mar 16, 2021
c15a3fa
日曜はじまりの2月の考慮処理を追加
Mar 17, 2021
394badf
インデント修正
Mar 17, 2021
89b7bfb
単体テスト追加
Mar 18, 2021
b51c09e
Webテスト実装中
Mar 18, 2021
171e6a1
管理画面の定休日カレンダー設定Webテスト実装完了
Mar 19, 2021
66ca6ab
未実装のテストをコメントアウト
Mar 19, 2021
043d9ee
スタイル追加と調整
Mar 24, 2021
2cdfcce
Webテスト実装
Mar 24, 2021
62fa8e4
タイポ修正
Mar 24, 2021
5d79b03
clearCacheの処理は不要なので削除
Mar 24, 2021
7825c91
削除メッセージをIDからタイトルへ修正
Mar 24, 2021
6e9bcc8
管理画面で定休日を修正した場合に重複チェックが発生するのを修正
Mar 24, 2021
8e18344
Create _12.9.calendar.scss
naomi-himoto Mar 25, 2021
4a74ca9
scss微修正と土日の定休日表示対応
Mar 25, 2021
e504c32
土日をテンプレートで定休日と変更したためテストを修正
Mar 25, 2021
ab39712
ロケール考慮漏れで定休日設定がずれていたのを修正
Mar 29, 2021
ca5b8b7
文言をmessage.yamlに切り出し
Mar 30, 2021
10fc475
Merge branch '4.1' into feature/calendar
Nov 24, 2021
95f1a48
レビュー指摘反映
Nov 24, 2021
706fa42
ユニットテストが落ちていたのを修正
Nov 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions app/DoctrineMigrations/Version20210316120000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210316120000 extends AbstractMigration
{
public function up(Schema $schema): void
{
// データ存在チェック
$count = $this->connection->fetchColumn("SELECT COUNT(*) FROM dtb_block WHERE block_name = 'カレンダー'");
if ($count > 0) {
return;
}

// idを取得する
$id = $this->connection->fetchColumn('SELECT MAX(id) FROM dtb_block');
$id++;

$this->addSql("INSERT INTO dtb_block (id, block_name, file_name, use_controller, deletable, create_date, update_date, device_type_id, discriminator_type) VALUES ($id, 'カレンダー', 'calendar', true, false, '2021-03-16 12:00:00', '2021-03-16 12:00:00', 10, 'block')");
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
}
}
3 changes: 3 additions & 0 deletions app/config/eccube/packages/eccube_nav.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ parameters:
shop_order_status:
name: admin.setting.shop.order_status_setting
url: admin_setting_shop_order_status
shop_calendar:
name: admin.setting.shop.calendar_setting
url: admin_setting_shop_calendar
system:
name: admin.setting.system
children:
Expand Down
78 changes: 78 additions & 0 deletions html/template/default/assets/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion html/template/default/assets/css/style.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion html/template/default/assets/css/style.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion html/template/default/assets/css/style.min.css.map

Large diffs are not rendered by default.

113 changes: 113 additions & 0 deletions html/template/default/assets/scss/project/_12.9.calendar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
@import "../mixins/media";
@import "../mixins/clearfix";

/*
見出し

トップページで使用されているカレンダーのスタイルです。

ex [トップページ](http://demo3.ec-cube.net/)

Markup:
sg-wrapper:
<div class="ec-role">
<sg-wrapper-content/>
</div>

Styleguide 12.9.1
*/

/* 背景や文字の色調整 */
$calander-default-bg: #F8F8F8;//月〜金までの背景色
$calander-default-color: #333;//月〜金までの文字色
$calander-sun-bg: #F8F8F8;//日曜の背景色
$calander-sun-color: #DE5D50;//日曜の文字色
$calander-sat-bg: #F8F8F8;//土曜の背景色
$calander-sat-color: #5CB1B1;//土曜の文字色

$calander-day-bg: #FFF;//日付の背景色
$calander-day-color: #333;//日付の文字色
$calander-holiday-bg: #FFF;//休日の背景色
$calander-holiday-color: #DE5D50;//休日の文字色
$calander-today-bg: #FFFDE7;//本日の背景色
$calander-today-color: #333;//本日の文字色

$calander-padding: 8px;//カレンダーの数字周りの余白

$calander-border: #f3f3f3;//カレンダーの線の色



.ec-calendar{
display: flex;
flex-direction: column;
flex-wrap: wrap;

@media screen and (min-width:768px){
flex-direction: row;
margin-left: -30px;
}

&__month{
border-collapse: collapse;
margin-top: 30px;
@media screen and (min-width:768px){
margin-top: 0;
margin-left: 30px;
}

th,td{
border-top: 1px solid $calander-border;
border-bottom: 1px solid $calander-border;
padding: $calander-padding;
text-align: center;
vertical-align: middle;
}//th,td
}//.ec-calendar__month
& &__title{
border: 0;
}//.ec-calendar__title
& &__sun{
background: $calander-sun-bg;
color: $calander-sun-color;
}//.ec-calendar__sun
& &__mon,
& &__tue,
& &__wed,
& &__thu,
& &__fri{
background: $calander-default-bg;
color: $calander-default-color;
}
& &__sat{
background: $calander-sat-bg;
color: $calander-sat-color;
}//.ec-calendar__sat
& &__day{
background: $calander-day-bg;
color: $calander-day-color;
}//.ec-calendar__day
& &__holiday{
background: $calander-holiday-bg;
color: $calander-holiday-color !important;
}//.ec-calendar__holiday
& &__today{
color: $calander-today-color;
position: relative;
z-index: 1;
&::before{
content:"";
position: absolute;
top: 50%;
left: 50%;
display: block;
width: 30px;
height: 30px;
border-radius: 50%;
background: $calander-today-bg;
transform: translate(-50%,-50%);
z-index: -1;
}
}//.ec-calendar__today

}//.ec-calendar
1 change: 1 addition & 0 deletions html/template/default/assets/scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ p {
@import "project/12.6.newItem";
@import "project/12.7.category";
@import "project/12.8.news";
@import "project/12.9.calendar";
@import "project/13.1.searchnav";
@import "project/13.2.shelf";
@import "project/13.3.pager";
Expand Down
129 changes: 129 additions & 0 deletions src/Eccube/Controller/Admin/Setting/Shop/CalendarController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?php

/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Eccube\Controller\Admin\Setting\Shop;

use Eccube\Controller\AbstractController;
use Eccube\Entity\Calendar;
use Eccube\Form\Type\Admin\CalendarType;
use Eccube\Repository\CalendarRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

/**
* Class CalendarController
*/
class CalendarController extends AbstractController
{
/**
* @var CalendarRepository
*/
protected $calendarRepository;

/**
* CalendarController constructor.
*
* @param CalendarRepository $calendarRepository
*/
public function __construct(CalendarRepository $calendarRepository)
{
$this->calendarRepository = $calendarRepository;
}

/**
* カレンダー設定の初期表示・登録
*
* @Route("/%eccube_admin_route%/setting/shop/calendar", name="admin_setting_shop_calendar")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

methods={"GET", "POST"} を指定お願いします

* @Route("/%eccube_admin_route%/setting/shop/calendar/new", name="admin_setting_shop_calendar_new")
* @Template("@admin/Setting/Shop/calendar.twig")
*/
public function index(Request $request)
{
$Calendar = new Calendar();
$builder = $this->formFactory
->createBuilder(CalendarType::class, $Calendar);

$form = $builder->getForm();

$mode = $request->get('mode');
if ($mode != 'edit_inline') {
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->entityManager->persist($Calendar);
$this->entityManager->flush();

$this->addSuccess('admin.common.save_complete', 'admin');

return $this->redirectToRoute('admin_setting_shop_calendar');
}
}

// カレンダーリスト取得
$Calendars = $this->calendarRepository->getListOrderByIdDesc();

$forms = [];
$errors = [];
/** @var Calendar $Calendar */
foreach ($Calendars as $Calendar) {
$builder = $this->formFactory->createBuilder(CalendarType::class, $Calendar);

$editCalendarForm = $builder->getForm();

// error number
$error = 0;
if ($mode == 'edit_inline'
&& $request->getMethod() === 'POST'
&& (string) $Calendar->getId() === $request->get('calendar_id')
) {
$editCalendarForm->handleRequest($request);
if ($editCalendarForm->isValid()) {
$calendarData = $editCalendarForm->getData();

$this->entityManager->persist($calendarData);
$this->entityManager->flush();

$this->addSuccess('admin.common.save_complete', 'admin');

return $this->redirectToRoute('admin_setting_shop_calendar');
}
$error = count($editCalendarForm->getErrors(true));
}

$forms[$Calendar->getId()] = $editCalendarForm->createView();
$errors[$Calendar->getId()] = $error;
}

return [
'Calendar' => $Calendar,
'Calendars' => $Calendars,
'form' => $form->createView(),
'forms' => $forms,
'errors' => $errors,
];
}

/**
* カレンダー設定の削除
*
* @Route("/%eccube_admin_route%/setting/shop/calendar/{id}/delete", requirements={"id" = "\d+"}, name="admin_setting_shop_calendar_delete", methods={"DELETE"})
*/
public function delete(Request $request, Calendar $Calendar)
{
$this->isTokenValid();
$this->calendarRepository->delete($Calendar);
$this->addSuccess('admin.common.delete_complete', 'admin');

return $this->redirectToRoute('admin_setting_shop_calendar');
}
}
Loading