Add location to events on schedule.

This commit is contained in:
Víðir Valberg Guðmundsson 2018-08-10 16:22:17 +02:00
parent 72f6d42ee2
commit 5ae96cfa6d
2 changed files with 275 additions and 170 deletions

View file

@ -123,14 +123,13 @@ eventDetailSidebar event model =
] ]
(videoRecordingLink (videoRecordingLink
++ [ speakerSidebar speakers ++ [ speakerSidebar speakers
, eventMetaDataSidebar event , eventMetaDataSidebar event eventInstances model
, eventInstancesSidebar eventInstances
] ]
) )
eventMetaDataSidebar : Event -> Html Msg eventMetaDataSidebar : Event -> List EventInstance -> Model -> Html Msg
eventMetaDataSidebar event = eventMetaDataSidebar event eventInstances model =
let let
( showVideoRecoring, videoRecording ) = ( showVideoRecoring, videoRecording ) =
case event.videoState of case event.videoState of
@ -142,9 +141,22 @@ eventMetaDataSidebar event =
_ -> _ ->
( False, "" ) ( False, "" )
eventInstanceMetaData =
case eventInstances of
[ instance ] ->
eventInstanceItem instance model
instances ->
[ h4 []
[ text "Multiple occurences:" ]
, ul
[]
(List.map (\ei -> li [] <| eventInstanceItem ei model) instances)
]
in in
div [] div []
[ h4 [] [ text "Metadata" ] ([ h4 [] [ text "Metadata" ]
, ul [] , ul []
([ li [] [ strong [] [ text "Type: " ], text event.eventType ] ([ li [] [ strong [] [ text "Type: " ], text event.eventType ]
] ]
@ -157,6 +169,43 @@ eventMetaDataSidebar event =
) )
) )
] ]
++ eventInstanceMetaData
)
eventInstanceItem : EventInstance -> Model -> List (Html Msg)
eventInstanceItem eventInstance model =
let
toFormat =
if Date.day eventInstance.from == Date.day eventInstance.to then
"HH:mm"
else
"E HH:mm"
( locationName, _ ) =
model.eventLocations
|> List.map unpackFilterType
|> List.filter
(\( _, locationSlug ) ->
locationSlug == eventInstance.location
)
|> List.head
|> Maybe.withDefault ( "Unknown", "" )
in
[ p []
[ strong [] [ text "When: " ]
, text
((Date.Extra.toFormattedString "E HH:mm" eventInstance.from)
++ " to "
++ (Date.Extra.toFormattedString toFormat eventInstance.to)
)
]
, p []
[ strong [] [ text "Where: " ]
, text <| locationName ++ " "
, i [ classList [ ( "fa", True ), ( "fa-" ++ eventInstance.locationIcon, True ) ] ] []
]
]
speakerSidebar : List Speaker -> Html Msg speakerSidebar : List Speaker -> Html Msg
@ -175,32 +224,3 @@ speakerDetail speaker =
li [] li []
[ a [ href <| routeToString <| SpeakerRoute speaker.slug ] [ text speaker.name ] [ a [ href <| routeToString <| SpeakerRoute speaker.slug ] [ text speaker.name ]
] ]
eventInstancesSidebar : List EventInstance -> Html Msg
eventInstancesSidebar eventInstances =
div []
[ h4 []
[ text "This event will occur at:" ]
, ul
[]
(List.map eventInstanceItem eventInstances)
]
eventInstanceItem : EventInstance -> Html Msg
eventInstanceItem eventInstance =
let
toFormat =
if Date.day eventInstance.from == Date.day eventInstance.to then
"HH:mm"
else
"E HH:mm"
in
li []
[ text
((Date.Extra.toFormattedString "E HH:mm" eventInstance.from)
++ " to "
++ (Date.Extra.toFormattedString toFormat eventInstance.to)
)
]

View file

@ -15706,50 +15706,6 @@ var _user$project$Views_DayView$dayView = F2(
}); });
}); });
var _user$project$Views_EventDetail$eventInstanceItem = function (eventInstance) {
var toFormat = _elm_lang$core$Native_Utils.eq(
_elm_lang$core$Date$day(eventInstance.from),
_elm_lang$core$Date$day(eventInstance.to)) ? 'HH:mm' : 'E HH:mm';
return A2(
_elm_lang$html$Html$li,
{ctor: '[]'},
{
ctor: '::',
_0: _elm_lang$html$Html$text(
A2(
_elm_lang$core$Basics_ops['++'],
A2(_justinmimbs$elm_date_extra$Date_Extra$toFormattedString, 'E HH:mm', eventInstance.from),
A2(
_elm_lang$core$Basics_ops['++'],
' to ',
A2(_justinmimbs$elm_date_extra$Date_Extra$toFormattedString, toFormat, eventInstance.to)))),
_1: {ctor: '[]'}
});
};
var _user$project$Views_EventDetail$eventInstancesSidebar = function (eventInstances) {
return A2(
_elm_lang$html$Html$div,
{ctor: '[]'},
{
ctor: '::',
_0: A2(
_elm_lang$html$Html$h4,
{ctor: '[]'},
{
ctor: '::',
_0: _elm_lang$html$Html$text('This event will occur at:'),
_1: {ctor: '[]'}
}),
_1: {
ctor: '::',
_0: A2(
_elm_lang$html$Html$ul,
{ctor: '[]'},
A2(_elm_lang$core$List$map, _user$project$Views_EventDetail$eventInstanceItem, eventInstances)),
_1: {ctor: '[]'}
}
});
};
var _user$project$Views_EventDetail$speakerDetail = function (speaker) { var _user$project$Views_EventDetail$speakerDetail = function (speaker) {
return A2( return A2(
_elm_lang$html$Html$li, _elm_lang$html$Html$li,
@ -15797,10 +15753,140 @@ var _user$project$Views_EventDetail$speakerSidebar = function (speakers) {
} }
}); });
}; };
var _user$project$Views_EventDetail$eventMetaDataSidebar = function (event) { var _user$project$Views_EventDetail$eventInstanceItem = F2(
var _p0 = function () { function (eventInstance, model) {
var _p1 = event.videoState; var _p0 = A2(
switch (_p1) { _elm_lang$core$Maybe$withDefault,
{ctor: '_Tuple2', _0: 'Unknown', _1: ''},
_elm_lang$core$List$head(
A2(
_elm_lang$core$List$filter,
function (_p1) {
var _p2 = _p1;
return _elm_lang$core$Native_Utils.eq(_p2._1, eventInstance.location);
},
A2(_elm_lang$core$List$map, _user$project$Models$unpackFilterType, model.eventLocations))));
var locationName = _p0._0;
var toFormat = _elm_lang$core$Native_Utils.eq(
_elm_lang$core$Date$day(eventInstance.from),
_elm_lang$core$Date$day(eventInstance.to)) ? 'HH:mm' : 'E HH:mm';
return {
ctor: '::',
_0: A2(
_elm_lang$html$Html$p,
{ctor: '[]'},
{
ctor: '::',
_0: A2(
_elm_lang$html$Html$strong,
{ctor: '[]'},
{
ctor: '::',
_0: _elm_lang$html$Html$text('When: '),
_1: {ctor: '[]'}
}),
_1: {
ctor: '::',
_0: _elm_lang$html$Html$text(
A2(
_elm_lang$core$Basics_ops['++'],
A2(_justinmimbs$elm_date_extra$Date_Extra$toFormattedString, 'E HH:mm', eventInstance.from),
A2(
_elm_lang$core$Basics_ops['++'],
' to ',
A2(_justinmimbs$elm_date_extra$Date_Extra$toFormattedString, toFormat, eventInstance.to)))),
_1: {ctor: '[]'}
}
}),
_1: {
ctor: '::',
_0: A2(
_elm_lang$html$Html$p,
{ctor: '[]'},
{
ctor: '::',
_0: A2(
_elm_lang$html$Html$strong,
{ctor: '[]'},
{
ctor: '::',
_0: _elm_lang$html$Html$text('Where: '),
_1: {ctor: '[]'}
}),
_1: {
ctor: '::',
_0: _elm_lang$html$Html$text(
A2(_elm_lang$core$Basics_ops['++'], locationName, ' ')),
_1: {
ctor: '::',
_0: A2(
_elm_lang$html$Html$i,
{
ctor: '::',
_0: _elm_lang$html$Html_Attributes$classList(
{
ctor: '::',
_0: {ctor: '_Tuple2', _0: 'fa', _1: true},
_1: {
ctor: '::',
_0: {
ctor: '_Tuple2',
_0: A2(_elm_lang$core$Basics_ops['++'], 'fa-', eventInstance.locationIcon),
_1: true
},
_1: {ctor: '[]'}
}
}),
_1: {ctor: '[]'}
},
{ctor: '[]'}),
_1: {ctor: '[]'}
}
}
}),
_1: {ctor: '[]'}
}
};
});
var _user$project$Views_EventDetail$eventMetaDataSidebar = F3(
function (event, eventInstances, model) {
var eventInstanceMetaData = function () {
var _p3 = eventInstances;
if ((_p3.ctor === '::') && (_p3._1.ctor === '[]')) {
return A2(_user$project$Views_EventDetail$eventInstanceItem, _p3._0, model);
} else {
return {
ctor: '::',
_0: A2(
_elm_lang$html$Html$h4,
{ctor: '[]'},
{
ctor: '::',
_0: _elm_lang$html$Html$text('Multiple occurences:'),
_1: {ctor: '[]'}
}),
_1: {
ctor: '::',
_0: A2(
_elm_lang$html$Html$ul,
{ctor: '[]'},
A2(
_elm_lang$core$List$map,
function (ei) {
return A2(
_elm_lang$html$Html$li,
{ctor: '[]'},
A2(_user$project$Views_EventDetail$eventInstanceItem, ei, model));
},
_p3)),
_1: {ctor: '[]'}
}
};
}
}();
var _p4 = function () {
var _p5 = event.videoState;
switch (_p5) {
case 'to-be-recorded': case 'to-be-recorded':
return {ctor: '_Tuple2', _0: true, _1: 'Yes'}; return {ctor: '_Tuple2', _0: true, _1: 'Yes'};
case 'not-to-be-recorded': case 'not-to-be-recorded':
@ -15809,11 +15895,13 @@ var _user$project$Views_EventDetail$eventMetaDataSidebar = function (event) {
return {ctor: '_Tuple2', _0: false, _1: ''}; return {ctor: '_Tuple2', _0: false, _1: ''};
} }
}(); }();
var showVideoRecoring = _p0._0; var showVideoRecoring = _p4._0;
var videoRecording = _p0._1; var videoRecording = _p4._1;
return A2( return A2(
_elm_lang$html$Html$div, _elm_lang$html$Html$div,
{ctor: '[]'}, {ctor: '[]'},
A2(
_elm_lang$core$Basics_ops['++'],
{ {
ctor: '::', ctor: '::',
_0: A2( _0: A2(
@ -15855,8 +15943,8 @@ var _user$project$Views_EventDetail$eventMetaDataSidebar = function (event) {
_1: {ctor: '[]'} _1: {ctor: '[]'}
}, },
function () { function () {
var _p2 = showVideoRecoring; var _p6 = showVideoRecoring;
if (_p2 === true) { if (_p6 === true) {
return { return {
ctor: '::', ctor: '::',
_0: A2( _0: A2(
@ -15886,30 +15974,31 @@ var _user$project$Views_EventDetail$eventMetaDataSidebar = function (event) {
}())), }())),
_1: {ctor: '[]'} _1: {ctor: '[]'}
} }
},
eventInstanceMetaData));
}); });
};
var _user$project$Views_EventDetail$getSpeakersFromSlugs = F3( var _user$project$Views_EventDetail$getSpeakersFromSlugs = F3(
function (speakers, slugs, collectedSpeakers) { function (speakers, slugs, collectedSpeakers) {
getSpeakersFromSlugs: getSpeakersFromSlugs:
while (true) { while (true) {
var _p3 = speakers; var _p7 = speakers;
if (_p3.ctor === '[]') { if (_p7.ctor === '[]') {
return collectedSpeakers; return collectedSpeakers;
} else { } else {
var _p7 = _p3._0; var _p11 = _p7._0;
var foundSlug = _elm_lang$core$List$head( var foundSlug = _elm_lang$core$List$head(
A2( A2(
_elm_lang$core$List$filter, _elm_lang$core$List$filter,
function (slug) { function (slug) {
return _elm_lang$core$Native_Utils.eq(slug, _p7.slug); return _elm_lang$core$Native_Utils.eq(slug, _p11.slug);
}, },
slugs)); slugs));
var foundSpeaker = function () { var foundSpeaker = function () {
var _p4 = foundSlug; var _p8 = foundSlug;
if (_p4.ctor === 'Just') { if (_p8.ctor === 'Just') {
return { return {
ctor: '::', ctor: '::',
_0: _p7, _0: _p11,
_1: {ctor: '[]'} _1: {ctor: '[]'}
}; };
} else { } else {
@ -15918,28 +16007,28 @@ var _user$project$Views_EventDetail$getSpeakersFromSlugs = F3(
}(); }();
var newCollectedSpeakers = A2(_elm_lang$core$Basics_ops['++'], collectedSpeakers, foundSpeaker); var newCollectedSpeakers = A2(_elm_lang$core$Basics_ops['++'], collectedSpeakers, foundSpeaker);
var newSlugs = function () { var newSlugs = function () {
var _p5 = foundSlug; var _p9 = foundSlug;
if (_p5.ctor === 'Just') { if (_p9.ctor === 'Just') {
return A2( return A2(
_elm_lang$core$List$filter, _elm_lang$core$List$filter,
function (x) { function (x) {
return !_elm_lang$core$Native_Utils.eq(x, _p5._0); return !_elm_lang$core$Native_Utils.eq(x, _p9._0);
}, },
slugs); slugs);
} else { } else {
return slugs; return slugs;
} }
}(); }();
var _p6 = slugs; var _p10 = slugs;
if (_p6.ctor === '[]') { if (_p10.ctor === '[]') {
return collectedSpeakers; return collectedSpeakers;
} else { } else {
var _v6 = _p3._1, var _v8 = _p7._1,
_v7 = newSlugs, _v9 = newSlugs,
_v8 = newCollectedSpeakers; _v10 = newCollectedSpeakers;
speakers = _v6; speakers = _v8;
slugs = _v7; slugs = _v9;
collectedSpeakers = _v8; collectedSpeakers = _v10;
continue getSpeakersFromSlugs; continue getSpeakersFromSlugs;
} }
} }
@ -15959,8 +16048,8 @@ var _user$project$Views_EventDetail$eventDetailSidebar = F2(
}, },
model.eventInstances); model.eventInstances);
var videoRecordingLink = function () { var videoRecordingLink = function () {
var _p8 = event.videoUrl; var _p12 = event.videoUrl;
if (_p8.ctor === 'Nothing') { if (_p12.ctor === 'Nothing') {
return {ctor: '[]'}; return {ctor: '[]'};
} else { } else {
return { return {
@ -15969,7 +16058,7 @@ var _user$project$Views_EventDetail$eventDetailSidebar = F2(
_elm_lang$html$Html$a, _elm_lang$html$Html$a,
{ {
ctor: '::', ctor: '::',
_0: _elm_lang$html$Html_Attributes$href(_p8._0), _0: _elm_lang$html$Html_Attributes$href(_p12._0),
_1: { _1: {
ctor: '::', ctor: '::',
_0: _elm_lang$html$Html_Attributes$classList( _0: _elm_lang$html$Html_Attributes$classList(
@ -16034,13 +16123,9 @@ var _user$project$Views_EventDetail$eventDetailSidebar = F2(
_0: _user$project$Views_EventDetail$speakerSidebar(speakers), _0: _user$project$Views_EventDetail$speakerSidebar(speakers),
_1: { _1: {
ctor: '::', ctor: '::',
_0: _user$project$Views_EventDetail$eventMetaDataSidebar(event), _0: A3(_user$project$Views_EventDetail$eventMetaDataSidebar, event, eventInstances, model),
_1: {
ctor: '::',
_0: _user$project$Views_EventDetail$eventInstancesSidebar(eventInstances),
_1: {ctor: '[]'} _1: {ctor: '[]'}
} }
}
})); }));
}); });
var _user$project$Views_EventDetail$eventDetailContent = function (event) { var _user$project$Views_EventDetail$eventDetailContent = function (event) {
@ -16135,9 +16220,9 @@ var _user$project$Views_EventDetail$eventDetailView = F2(
return _elm_lang$core$Native_Utils.eq(e.slug, eventSlug); return _elm_lang$core$Native_Utils.eq(e.slug, eventSlug);
}, },
model.events)); model.events));
var _p9 = event; var _p13 = event;
if (_p9.ctor === 'Just') { if (_p13.ctor === 'Just') {
var _p10 = _p9._0; var _p14 = _p13._0;
return A2( return A2(
_elm_lang$html$Html$div, _elm_lang$html$Html$div,
{ {
@ -16147,10 +16232,10 @@ var _user$project$Views_EventDetail$eventDetailView = F2(
}, },
{ {
ctor: '::', ctor: '::',
_0: _user$project$Views_EventDetail$eventDetailContent(_p10), _0: _user$project$Views_EventDetail$eventDetailContent(_p14),
_1: { _1: {
ctor: '::', ctor: '::',
_0: A2(_user$project$Views_EventDetail$eventDetailSidebar, _p10, model), _0: A2(_user$project$Views_EventDetail$eventDetailSidebar, _p14, model),
_1: {ctor: '[]'} _1: {ctor: '[]'}
} }
}); });