{"version":3,"file":"uppsala.localplanlist-searchform.min.js","names":["define","$","localplanlistmap","groupableAutocomplete","toggleSwitch","tabPanel","clearableSearchField","multiselect","_toggleSwitchQueryParameterKey","_pageQueryParameterKey","_stagesQueryParameterKey","_isAjaxQueryParameterKey","_toggleSwitchListOptionId","_toggleSwitchMapOptionId","autocompleteSuggestionEndpoint","formSelector","legendProperty","legendPropertyRegex","RegExp","localplanlistSearchform","init","suggestionEndpoint","pageQueryParameterKey","stagesQueryParameterKey","isAjaxQueryParameterKey","toggleSwitchQueryParameterKey","toggleSwitchListOptionId","toggleSwitchMapOptionId","this","initFormComponents","initialState","getActiveFiltersState","window","history","replaceState","title","querystring","shouldShowPropertyLegend","on","e","preventDefault","event","key","addEventListener","urlParams","URLSearchParams","location","search","populateFormFromUrl","setActiveTabFromUrl","refreshMultiSelects","refreshSearchResult","refreshFilterLabels","groupableAutcompleteOnChange","initButtonToggle","toggleSwitchOnChange","multiselectOnChange","addClearFilterLinkEventListener","activeTab","getActiveTabId","refreshTabs","filterList","goToSelectedSuggestion","applyFilters","currentTabQuery","data","serialize","path","pathname","substr","ajax","url","type","dataType","success","response","html","error","request","status","errorThrown","urlValue","get","$buttonToSetToActive","transformToggleSwitchPointer","currentState","pushStateToUrl","document","currentUrl","attr","clearFilterFromClearLinkUrl","clearFilterUrl","queryParams","URL","searchParams","query","getActivePage","state","pushState","populateFormStagesFromUrl","populateFormInputFromUrl","stagesInUrl","getAll","each","filterValue","val","currentFilterIsActive","includes","checked","inputSelector","$formElement","name","toggleSwitchSelector","page","currentFilters","filters","filter","test","show","hide","resetPaging","$formData","value","undefined","push","activeTabId","activePage"],"sources":["uppsala.localplanlist-searchform.js"],"mappings":"AAAAA,OAAO,CACH,SACA,mBACA,wBACA,eACA,WACA,uBACA,gBACA,SACIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,GAEA,IAcIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EAbAC,EAAe,+BAKfC,EAAiB,0B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ch\",\n \"tabPanel\",\n \"clearablesearchfield\",\n \"multiselect\"],\n function (\n $,\n localplanlistmap,\n groupableAutocomplete,\n toggleSwitch,\n tabPanel,\n clearableSearchField,\n multiselect) {\n\n var filterOptionsSelector = \"#multiselect_stages input\";\n var queryInputSelector = \"#js-localplanlist-autocomplete-input\";\n var diarienrInputSelector = \"#js-selectedautocompleteoption-diarienr\";\n var aktbeteckningInputSelector = \"#js-selectedautocompleteoption-aktbeteckning\";\n var optionLayerTypeInputSelector = \"#js-selectedautocompleteoption-layertype\";\n var optionIdInputSelector = \"#js-selectedautocompleteoption-id\";\n var optionTextInputSelector = \"#js-selectedautocompleteoption-text\";\n var toggleSwitchSelector = \".js-toggle-element\";\n var formSelector = \"#js-localplanlist-searchform\";\n var clearableInputField = \".js-clearable-input\";\n var listSelector = \".js-localplanlist\";\n var clearFilterLinkSelector = \".js-clearfilter-link\";\n var mapActiveFiltersSelector = \"#js-map-activefilters\";\n var legendProperty = \"#arcgis-legend-property\"\n var _toggleSwitchQueryParameterKey;\n var _pageQueryParameterKey;\n var _stagesQueryParameterKey;\n //set isAjax to false when pushing querystring to history to avoid triggering ajax request when tabbing back and forth in browser history\n var _isAjaxQueryParameterKey;\n var _toggleSwitchListOptionId;\n var _toggleSwitchMapOptionId;\n var autocompleteSuggestionEndpoint;\n\n const legendPropertyRegex = new RegExp('.+[\\\\s]+[\\\\d]+:[\\\\d]+');\n\n var localplanlistSearchform = {\n init: function (\n suggestionEndpoint,\n pageQueryParameterKey,\n stagesQueryParameterKey,\n isAjaxQueryParameterKey,\n toggleSwitchQueryParameterKey,\n toggleSwitchListOptionId,\n toggleSwitchMapOptionId) {\n\n autocompleteSuggestionEndpoint = suggestionEndpoint;\n _pageQueryParameterKey = pageQueryParameterKey;\n _stagesQueryParameterKey = stagesQueryParameterKey;\n _isAjaxQueryParameterKey = isAjaxQueryParameterKey;\n _toggleSwitchQueryParameterKey = toggleSwitchQueryParameterKey;\n _toggleSwitchListOptionId = toggleSwitchListOptionId;\n _toggleSwitchMapOptionId = toggleSwitchMapOptionId;\n this.initFormComponents();\n\n //set inital state to include in history\n var initialState = this.getActiveFiltersState();\n window.history.replaceState(initialState, initialState.title, \"?\" + initialState.querystring);\n \n this.shouldShowPropertyLegend();\n\n $(formSelector).on('submit', function (e) {\n e.preventDefault();\n });\n\n $(clearableInputField).on(\"keydown\", function (event) {\n return event.key != \"Enter\";\n });\n\n //event triggered when navigting back and forth in browser hostory\n window.addEventListener('popstate', () => {\n\n //read current state from url\n const urlParams = new URLSearchParams(window.location.search);\n this.populateFormFromUrl(urlParams);\n this.setActiveTabFromUrl(urlParams);\n\n //refresh multiselect filter\n multiselect.refreshMultiSelects();\n\n //refresh result in list or map\n localplanlistSearchform.refreshSearchResult();\n localplanlistSearchform.refreshFilterLabels();\n });\n },\n initFormComponents: function () {\n groupableAutocomplete.init(autocompleteSuggestionEndpoint, this.groupableAutcompleteOnChange, \"Välj något av förslagen i listan\");\n tabPanel.init();\n toggleSwitch.initButtonToggle(\".toggle-switch--button\", \".active.js-toggle-element\", \"#js-toggle-switch-pointer\", \"#js-toggle-switch\", this.toggleSwitchOnChange, _toggleSwitchQueryParameterKey);\n clearableSearchField.init();\n multiselect.init(this.multiselectOnChange);\n localplanlistSearchform.addClearFilterLinkEventListener();\n },\n refreshSearchResult: function () {\n //refresh tabs\n var activeTab = localplanlistSearchform.getActiveTabId();\n tabPanel.refreshTabs(activeTab);\n\n //refresh list if current tab is list\n if (activeTab == _toggleSwitchListOptionId) {\n localplanlistSearchform.filterList();\n }\n //refresh map if current tab is map\n else if (activeTab == _toggleSwitchMapOptionId) {\n localplanlistmap.goToSelectedSuggestion();\n localplanlistmap.applyFilters();\n localplanlistSearchform.refreshFilterLabels();\n }\n },\n refreshFilterLabels: function () {\n //tab is only available in url \n //the form is the source for all other filters\n let currentTabQuery = \"&\" + _toggleSwitchQueryParameterKey + \"=\" + localplanlistSearchform.getActiveTabId();\n let data = $(formSelector).serialize() + currentTabQuery;\n\n //get url path and check if its missing a trailing slash \"/\"\n //add if its missing, otherwise we'll get a 404 on GetActiveFiltersView\n let path = window.location.pathname;\n if (path.substr(-1) != '/') path += '/';\n\n $.ajax({\n url: path + \"GetActiveFiltersView\",\n data: data,\n type: \"get\",\n dataType: \"html\",\n success: function (response) {\n $(mapActiveFiltersSelector).html(response);\n },\n error: function (request, status, errorThrown) {\n //avkommentera vid felsökning\n //console.log(\"epic fail: \" + errorThrown + \", \" + status);\n }\n });\n\n this.shouldShowPropertyLegend();\n },\n setActiveTabFromUrl: function (urlParams) {\n var urlValue = urlParams.get(_toggleSwitchQueryParameterKey);\n var $buttonToSetToActive = $(\"#\" + urlValue);\n toggleSwitch.transformToggleSwitchPointer($buttonToSetToActive, \"#js-toggle-switch-pointer\", \".toggle-switch--button\", $(\"#js-toggle-switch\"));\n },\n //passed on as callback to groupableAutcomplete component\n groupableAutcompleteOnChange: function () {\n const resetPaging = true;\n var currentState = localplanlistSearchform.getActiveFiltersState(resetPaging);\n localplanlistSearchform.pushStateToUrl(currentState);\n var activeTab = localplanlistSearchform.getActiveTabId();\n\n if (activeTab == _toggleSwitchListOptionId) {\n localplanlistSearchform.filterList();\n }\n else if (activeTab == _toggleSwitchMapOptionId) {\n localplanlistmap.goToSelectedSuggestion();\n localplanlistmap.applyFilters();\n localplanlistSearchform.refreshFilterLabels();\n }\n },\n //passed on as callback to multiselect component\n multiselectOnChange: function () {\n const resetPaging = true;\n var currentState = localplanlistSearchform.getActiveFiltersState(resetPaging);\n localplanlistSearchform.pushStateToUrl(currentState);\n var activeTab = localplanlistSearchform.getActiveTabId();\n if (activeTab == _toggleSwitchListOptionId) {\n localplanlistSearchform.filterList();\n }\n else if (activeTab == _toggleSwitchMapOptionId) {\n localplanlistmap.applyFilters();\n localplanlistSearchform.refreshFilterLabels();\n }\n },\n //adds a click event to a 'clear filter link' (check out class .bullet--link)\n //a 'clear filter link' is a link with the filter to be cleared missing from the querystring\n //normally causes a page reload\n //this function updates the filtered view without a page reload\n addClearFilterLinkEventListener: function () {\n $(document).on(\"click\", clearFilterLinkSelector, function (event) {\n event.preventDefault();\n var currentUrl = $(this).attr(\"href\");\n localplanlistSearchform.clearFilterFromClearLinkUrl(currentUrl);\n });\n },\n clearFilterFromClearLinkUrl: function (clearFilterUrl) {\n //retrieve query parameters from current clearFilterUrl\n var url = new URL(clearFilterUrl);\n let queryParams = url.searchParams;\n\n //the form is used as 'master source' for filter data by other functions\n //therefore we populate it based on the clearFilterUrl\n localplanlistSearchform.populateFormFromUrl(queryParams);\n\n //retrieve updated state object for form/filters and push to browser url\n const resetPaging = true;\n var currentState = localplanlistSearchform.getActiveFiltersState(resetPaging);\n localplanlistSearchform.pushStateToUrl(currentState);\n\n //refresh multiselect component and the searchresult\n multiselect.refreshMultiSelects();\n localplanlistSearchform.refreshSearchResult();\n },\n //passed on as callback to toggleSwitch component\n toggleSwitchOnChange: function () {\n var currentState = localplanlistSearchform.getActiveFiltersState();\n localplanlistSearchform.pushStateToUrl(currentState);\n var activeTab = localplanlistSearchform.getActiveTabId();\n\n if (activeTab == _toggleSwitchListOptionId) {\n localplanlistSearchform.filterList();\n }\n else if (activeTab == _toggleSwitchMapOptionId) {\n localplanlistmap.goToSelectedSuggestion();\n localplanlistmap.applyFilters();\n localplanlistSearchform.refreshFilterLabels();\n }\n },\n //ajax call to controller to get a local plan list filtered based on form data, active tab and paging value\n filterList: function () {\n\n //query is form data + active tab and page\n //set isAjax to true to return partial view with local plan list items. \n //see other places where isAjax is used to see when it should be set to false\n var query = $(formSelector).serialize()\n + \"&\" + _toggleSwitchQueryParameterKey + \"=\" + this.getActiveTabId()\n + \"&\" + _pageQueryParameterKey + \"=\" + this.getActivePage()\n + \"&\" + _isAjaxQueryParameterKey + \"=true\";\n\n $.ajax({\n url: window.location.pathname,\n data: query,\n type: \"get\",\n dataType: \"html\",\n success: function (response) {\n $(listSelector).html(response);\n },\n error: function (request, status, errorThrown) {\n //avkommentera vid felsökning\n //console.log(\"epic fail: \" + errorThrown + \", \" + status);\n }\n });\n },\n //pushes filter changes to history\n pushStateToUrl: function (state) {\n // push to url/history\n window.history.pushState({ state: state }, document.title, \"?\" + state.querystring);\n },\n //used to populate the form with with current url data when the user is stepping back and forth in browser history \n //also used when clearing filters with the 'clear filter links' (check out .bullet--link)\n populateFormFromUrl: function (urlParams) {\n this.populateFormStagesFromUrl(urlParams);\n this.populateFormInputFromUrl(urlParams, queryInputSelector);\n this.populateFormInputFromUrl(urlParams, aktbeteckningInputSelector);\n this.populateFormInputFromUrl(urlParams, diarienrInputSelector);\n this.populateFormInputFromUrl(urlParams, optionIdInputSelector);\n this.populateFormInputFromUrl(urlParams, optionTextInputSelector);\n this.populateFormInputFromUrl(urlParams, optionLayerTypeInputSelector);\n },\n //used to populate the stages mltiselect with with current url data when the user is stepping back and forth in browser history \n populateFormStagesFromUrl: function (urlParams) {\n //get all stages in url\n var stagesInUrl = urlParams.getAll(_stagesQueryParameterKey);\n\n // get inputs, look for value in querystring, set value on element, else clear value\n $(filterOptionsSelector).each(function () {\n var filterValue = $(this).val();\n var currentFilterIsActive = stagesInUrl.includes(filterValue);\n $(this)[0].checked = currentFilterIsActive;\n });\n },\n //set form input to current value in url\n populateFormInputFromUrl: function (urlParams, inputSelector) {\n var $formElement = $(inputSelector);\n var name = $(inputSelector).attr('name');\n\n var urlValue = urlParams.get(name);\n //if there is a value in url, insert that value\n if (urlValue) {\n $formElement.val(urlValue);\n }\n //else clear form value\n else {\n $formElement.val(\"\");\n }\n },\n //gets the active value for list or map tab from url\n getActiveTabId: function () {\n var selector = toggleSwitchSelector + \"[aria-selected='true']\";\n var activeTab = $(selector).attr(\"id\");\n return activeTab;\n },\n //gets active paging value from url\n getActivePage: function () {\n const urlParams = new URLSearchParams(window.location.search);\n var page = urlParams.get(\"page\");\n if (page) {\n return page;\n }\n else {\n return \"\";\n }\n },\n // Checks currentFilters against regex to determine whether or not to show property legend\n shouldShowPropertyLegend: function () {\n var currentFilters = localplanlistSearchform.getActiveFiltersState().filters\n\n for (var filter of currentFilters) {\n if (legendPropertyRegex.test(filter?.name)) {\n $(legendProperty).show();\n return;\n } \n }\n \n $(legendProperty).hide();\n },\n //creates a state object with active filters. collects values from form and url (for values that doesnt exist in form)\n //state object is used when pushing filter changes to history\n getActiveFiltersState: function (resetPaging = false) {\n var state = { filters: [] };\n var $formData = $(formSelector + \" input:not(.js-history-exclude)\");\n\n //add form data to state\n $formData.each(function () {\n var value = $(this).attr('value');\n var name = $(this).attr('name');\n\n if (name == undefined || name == 'undefined') {\n return true;\n }\n state.filters.push({ name: value });\n });\n\n //toggle switch and paging is not part of form, we need to add separately\n var activeTabId = localplanlistSearchform.getActiveTabId();\n var activePage = resetPaging ? \"\" : localplanlistSearchform.getActivePage();\n state.filters.push({ toggleSwitchQueryParameterKey: activeTabId });\n state.filters.push({ pageQueryParameterKey: activePage });\n\n //add form data and toggle switch to querystring\n //set isAjax to false when pushing querystring to history to avoid triggering ajax request when tabbing back and forth in browser history\n state.querystring = $formData.serialize() +\n \"&\" + _toggleSwitchQueryParameterKey + \"=\" + activeTabId +\n \"&\" + _pageQueryParameterKey + \"=\" + activePage +\n \"&\" + _isAjaxQueryParameterKey + \"=false\";\n\n return state;\n }\n };\n\n return localplanlistSearchform;\n });"]}