1
00:00:01,650 --> 00:00:07,770
So we have our handlers set up, we have a form tag around our entire calendar and we have the route

2
00:00:07,790 --> 00:00:11,790
set up and there's a few other things we need to do before we can actually work with things.

3
00:00:11,800 --> 00:00:16,920
Remember what we want to do here, and this is all we're working on right now is if I uncheck this date

4
00:00:17,220 --> 00:00:22,770
and click save changes, I want to come back to this page whatever month and year I'm currently looking

5
00:00:22,770 --> 00:00:23,040
at.

6
00:00:23,580 --> 00:00:25,980
And I want that block to be removed.

7
00:00:26,340 --> 00:00:31,830
But if I click say this one, which was not checked to start with and click save changes, then I want

8
00:00:32,160 --> 00:00:35,640
to come back to the current page I'm looking at and have this checked.

9
00:00:35,850 --> 00:00:40,170
So what I should be able to check and uncheck things in the same step.

10
00:00:41,040 --> 00:00:44,850
So the first thing to bear in mind is I need to be able to come back to whatever month I'm looking at.

11
00:00:44,970 --> 00:00:47,490
Right now, as I recall, this is December 2020.

12
00:00:47,500 --> 00:00:49,080
Christmas is just a few days away.

13
00:00:49,080 --> 00:00:54,000
But what if I'm looking at this month and I want to block these two dates and click save changes?

14
00:00:54,210 --> 00:00:57,420
I don't want to go back to December 2020, which is the current month.

15
00:00:57,420 --> 00:01:00,460
I want to come back to the one that I was last looking at.

16
00:01:00,990 --> 00:01:03,000
So there's a few changes I need to make.

17
00:01:03,000 --> 00:01:07,350
So I'm going to go back to my I.D. I'm going to find my reservations calendar.

18
00:01:07,770 --> 00:01:14,460
And at the top here in the after this input type equals hidden for CSF token, I'm going to duplicate

19
00:01:14,460 --> 00:01:21,870
that twice and I'm going to call the first one I created M for month and the next one why for a year.

20
00:01:22,140 --> 00:01:26,790
And the value that I'm going to display in there is actually the current month and the current year.

21
00:01:26,790 --> 00:01:33,780
And I already have those in the string maps so I can pull those right out of their index dot string

22
00:01:33,780 --> 00:01:34,320
map.

23
00:01:34,740 --> 00:01:38,730
And the value that I'm looking for is this month.

24
00:01:40,260 --> 00:01:45,450
And this one is going to be also from the index dot string map.

25
00:01:45,450 --> 00:01:48,210
And if you recall, I called that one this month.

26
00:01:48,450 --> 00:01:48,810
Year.

27
00:01:49,610 --> 00:01:52,860
OK, so let's save that reload this page.

28
00:01:53,040 --> 00:01:54,210
I'll just reload this one.

29
00:01:54,630 --> 00:02:02,160
And if I look at this and come down to the search for the word hidden there, they're zero three and

30
00:02:02,160 --> 00:02:02,940
twenty twenty one.

31
00:02:02,940 --> 00:02:03,480
Perfect.

32
00:02:03,540 --> 00:02:04,260
That's what I need.

33
00:02:04,270 --> 00:02:05,630
So I'm definitely going to want to have that.

34
00:02:06,390 --> 00:02:12,270
The other thing to bear in mind, if we scroll down here to this input where I'm displaying the checkbox,

35
00:02:12,840 --> 00:02:16,920
if there is a block in place, I'm checking it.

36
00:02:16,920 --> 00:02:18,810
I give it a name and I give it a value.

37
00:02:19,140 --> 00:02:26,580
But if there's none, if there is no value in index, in the map blocks that I'm just giving it a name,

38
00:02:26,610 --> 00:02:28,620
I actually need to give it a value, too.

39
00:02:28,650 --> 00:02:32,040
Otherwise it's not actually going to get past it.

40
00:02:32,370 --> 00:02:35,610
It won't actually get submitted to the form with any meaningful value.

41
00:02:35,610 --> 00:02:36,780
I'm just going to give it one.

42
00:02:36,810 --> 00:02:39,570
Anything greater than zero will suffice.

43
00:02:39,750 --> 00:02:40,830
So I've made that change.

44
00:02:41,700 --> 00:02:45,780
Now let's go back to our handlers and start thinking about what we're going to do.

45
00:02:45,780 --> 00:02:49,830
Well, the very first thing that I'm doing is I'm posting a form here, so I'll do what I always do

46
00:02:49,830 --> 00:02:52,110
when I when I post a form is I'll pass the form.

47
00:02:53,130 --> 00:02:54,960
Otherwise I can't even write tests for this.

48
00:02:55,140 --> 00:02:56,520
So I'll pass the form.

49
00:02:56,520 --> 00:02:59,610
If error is not equal to nil are standard error check.

50
00:02:59,610 --> 00:03:06,180
And because I'm in the admin here, all I really care about is helper server error w and error and the

51
00:03:06,180 --> 00:03:06,600
return.

52
00:03:07,890 --> 00:03:10,050
OK, which needs to be spelled correctly.

53
00:03:11,190 --> 00:03:13,080
So I've passed my form data.

54
00:03:13,200 --> 00:03:14,790
Now I can actually do something with it.

55
00:03:14,790 --> 00:03:21,510
So those two hidden fields I just added Y and M I'm going to grab those so I can do my redirect appropriately,

56
00:03:21,510 --> 00:03:26,730
appropriately year and I'm going to ignore the error because it's a hidden field that I know is there

57
00:03:27,120 --> 00:03:36,180
is stewart-cousins a2 I and I'm getting asked form douget and this is the year so I and in the one y

58
00:03:36,570 --> 00:03:43,650
and then we'll do month, month and M and now let's do our redirect.

59
00:03:44,700 --> 00:03:50,070
The last thing I do after all of my processing takes place and I'm skipping that step right now is to

60
00:03:50,070 --> 00:03:50,520
redirect.

61
00:03:50,520 --> 00:04:02,580
So I'll just put a message in the session AMD app session put and our context as always, Flash and

62
00:04:02,580 --> 00:04:03,690
I'll lie to us right now.

63
00:04:04,080 --> 00:04:07,800
Changes saved and it's alive because we haven't actually saved the changes yet.

64
00:04:08,280 --> 00:04:11,220
And then we'll do an EDP redirect.

65
00:04:13,330 --> 00:04:20,770
Which requires a response writer appointed to request the Yucel, which will in this case not just be

66
00:04:20,770 --> 00:04:24,320
the name of the calendar page.

67
00:04:24,340 --> 00:04:26,400
I want to take them back to the correct.

68
00:04:26,410 --> 00:04:27,000
You are out.

69
00:04:27,550 --> 00:04:36,910
So we'll use a format as print F format that s print F, and we're going to take them to admin's reservations

70
00:04:36,910 --> 00:04:46,990
calendar and we're going to put Y equals with a with a placeholder for Int and M equals and a placeholder

71
00:04:46,990 --> 00:04:54,490
for an int and the placeholders will be year and month and we need to give them some status http status

72
00:04:54,490 --> 00:04:55,000
c other.

73
00:04:55,810 --> 00:05:01,930
OK, so let's just make sure this works before we go any further so we'll stop this started up again.

74
00:05:04,210 --> 00:05:10,870
And go back to our calendar and I'll click on this one and I'll go to say February twenty twenty one

75
00:05:10,870 --> 00:05:12,070
and I'll just click save changes.

76
00:05:12,070 --> 00:05:13,000
I'll actually check this.

77
00:05:13,000 --> 00:05:15,970
It won't do anything with it, but I'll check it and see safe changes.

78
00:05:16,370 --> 00:05:21,310
And it took me back to February twenty twenty one and it lied to me and said changes are saved.

79
00:05:21,970 --> 00:05:23,290
So that part is working.

80
00:05:23,800 --> 00:05:30,460
The next step is to actually handle the posted blocks and unlocks things that are checked that weren't

81
00:05:30,460 --> 00:05:34,120
before and things that are, that are not checked that were before.

82
00:05:34,120 --> 00:05:39,540
So we actually need to handle that logic in our code right about here.

83
00:05:40,030 --> 00:05:43,660
So this is where we're going to process Bloks.

84
00:05:46,680 --> 00:05:49,350
And we'll get started with that in the next lecture.
