1
1

00:00:00,900  -->  00:00:02,410 line:15% 
<v Jose>Hi, welcome back.</v>
2

2

00:00:02,410  -->  00:00:03,540 line:15% 
In this video we're going to be
3

3

00:00:03,540  -->  00:00:07,958 line:15% 
linking up our alert index into our edit.
4

4

00:00:07,958  -->  00:00:11,954
All we have to do is go into this list group item
5

5

00:00:11,954  -->  00:00:16,500
and this list group item runs for every alert
6

6

00:00:16,500  -->  00:00:18,530
in our alerts list.
7

7

00:00:18,530  -->  00:00:21,110
That means that we have an alert object
8

8

00:00:21,110  -->  00:00:24,686
and we can access the underscore ID property of it.
9

9

00:00:24,686  -->  00:00:27,480
So within this for loop we can access
10

10

00:00:27,480  -->  00:00:30,230
the underscore ID property of each alert
11

11

00:00:30,230  -->  00:00:32,480
which means inside this list group item
12

12

00:00:32,480  -->  00:00:36,430
we could potentially add the button
13

13

00:00:36,430  -->  00:00:38,820
that will take us to the edit.
14

14

00:00:38,820  -->  00:00:41,180
So we're going to say A, class is going to be btn,
15

15

00:00:41,180  -->  00:00:43,350
btn dash secondary,
16

16

00:00:43,350  -->  00:00:47,380
That is just a slightly less important button on the page.
17

17

00:00:47,380  -->  00:00:49,501
You'll see what it looks like in just a moment.
18

18

00:00:49,501  -->  00:00:54,501
The href is going to be url for alerts dot edit alert
19

19

00:00:55,600  -->  00:00:57,333
which is our endpoint.
20

20

00:00:58,620  -->  00:01:02,600
And then we're going to have something like
21

21

00:01:02,600  -->  00:01:04,450
the word edit in here.
22

22

00:01:04,450  -->  00:01:09,160
Now, something I'm missing from this href is the alert ID.
23

23

00:01:09,160  -->  00:01:10,580
As you can see I said that we can access
24

24

00:01:10,580  -->  00:01:12,807
the underscore ID property of the alert
25

25

00:01:12,807  -->  00:01:15,275
but we are not accessing it anyway here.
26

26

00:01:15,275  -->  00:01:20,275
The url for function takes in the method,
27

27

00:01:21,310  -->  00:01:24,320
sorry, the function name inside the blueprint
28

28

00:01:24,320  -->  00:01:26,656
that we want to send the users to,
29

29

00:01:26,656  -->  00:01:31,656
but it can also take extra arguments,
30

30

00:01:31,910  -->  00:01:36,910
one argument for each thing that this function expects.
31

31

00:01:37,730  -->  00:01:40,460
So if we go the alert views,
32

32

00:01:40,460  -->  00:01:43,130
you can see that this function expects an alert ID
33

33

00:01:43,130  -->  00:01:47,136
to be passed to it in order to be able to then load.
34

34

00:01:47,136  -->  00:01:52,136
So in here, after the quotations which contain
35

35

00:01:52,640  -->  00:01:56,590
the function name we're going to say alert underscore ID
36

36

00:01:56,590  -->  00:01:59,410
which is the name that we're expecting here,
37

37

00:01:59,410  -->  00:02:03,471
alert underscore ID, it is going to be alert,
38

38

00:02:03,471  -->  00:02:07,023
which is this thing that we are using to iterate,
39

39

00:02:07,023  -->  00:02:10,080
dot underscore ID, which is going to load
40

40

00:02:10,080  -->  00:02:12,673
the underscore ID property of the alert object.
41

41

00:02:14,450  -->  00:02:15,720
And that's it.
42

42

00:02:15,720  -->  00:02:17,642
Now we can go and run our app,
43

43

00:02:17,642  -->  00:02:21,393
making sure of course that Mungo DB is running,
44

44

00:02:21,393  -->  00:02:22,800
and we can try it out.
45

45

00:02:22,800  -->  00:02:27,780
So I'm going to go here and there you have this edit button.
46

46

00:02:27,780  -->  00:02:29,475
You can click it and it takes you over to
47

47

00:02:29,475  -->  00:02:34,470
slash alerts slash edit slash the alert ID.
48

48

00:02:34,470  -->  00:02:37,660
And we can change it, we can set it 3000 same.
49

49

00:02:37,660  -->  00:02:38,973
And there you have that.
50

50

00:02:40,100  -->  00:02:42,963
If you click edit again, you should see 3000
51

51

00:02:42,963  -->  00:02:45,110
is in the price limit,
52

52

00:02:45,110  -->  00:02:46,310
and if you go into Mungo DB,
53

53

00:02:46,310  -->  00:02:48,410
you'll see that it's there as well.
54

54

00:02:48,410  -->  00:02:50,520
So something important to notice is that
55

55

00:02:50,520  -->  00:02:52,310
no more alerts were created.
56

56

00:02:52,310  -->  00:02:53,848
So this one was updated,
57

57

00:02:53,848  -->  00:02:57,163
that is what we coded in our endpoint.
58

58

00:02:58,175  -->  00:03:01,360
So that is how you can think about
59

59

00:03:01,360  -->  00:03:03,810
interacting with individual items.
60

60

00:03:03,810  -->  00:03:07,060
Because we've got this list of items that we're showing
61

61

00:03:07,060  -->  00:03:09,680
within that list we can add actions
62

62

00:03:09,680  -->  00:03:12,810
that a user can take, or an individual item.
63

63

00:03:12,810  -->  00:03:16,260
If we want something more higher level
64

64

00:03:16,260  -->  00:03:19,800
to effect all the alerts, say like creating a new alert,
65

65

00:03:19,800  -->  00:03:22,600
we would not put that inside this loop.
66

66

00:03:22,600  -->  00:03:24,210
We would put it outside because
67

67

00:03:24,210  -->  00:03:26,860
it's unrelated to an individual alert.
68

68

00:03:26,860  -->  00:03:30,430
So in the loop, we talk about individual alerts, each one,
69

69

00:03:30,430  -->  00:03:33,040
and outside the loop we can do something a bit more generic
70

70

00:03:33,040  -->  00:03:35,069
like creating new alerts, or potentially
71

71

00:03:35,069  -->  00:03:37,990
deleting all the alerts or something like that
72

72

00:03:37,990  -->  00:03:40,746
if that's what you're wanting to add in.
73

73

00:03:40,746  -->  00:03:42,610
Thanks for joining me in this video.
74

74

00:03:42,610  -->  00:03:43,920
I hope that was useful.
75

75

00:03:43,920  -->  00:03:45,370
I'll see you in the next one.
