diff --git a/app/assets/javascripts/admin_legacy/modules/document_finder.js b/app/assets/javascripts/admin_legacy/modules/document_finder.js
deleted file mode 100644
index 715cede8fba..00000000000
--- a/app/assets/javascripts/admin_legacy/modules/document_finder.js
+++ /dev/null
@@ -1,109 +0,0 @@
-(function () {
- 'use strict'
- var root = this
- var $ = root.jQuery
-
- if (typeof root.GOVUK === 'undefined') { root.GOVUK = {} }
-
- var documentFinder = {
- // This object is re-usable. All it relies upon to work is an input
- // with an id of 'title' (though you could easily configure that),
- // a button with an id of '#find-documents', and a hidden field to
- // store the selected document's id (with a name attribute of
- // 'document_id') or edition's id (with a name attribute of 'edition_id').
-
- init: function (params) {
- this.noResultsMessage = params.no_results_message || 'No results matching search criteria'
- delete params.no_results_message
- this.additionalFilterParams = params
- this.latestResults = null
- this.searchTermContent = ''
- this.$searchTerm = $('input#title')
- this.$searchTerm.autocomplete({
- disabled: true,
- minLength: 0,
- select: function (event, ui) {
- documentFinder.selectDocFromMenu(event, ui)
- }
- })
- this.$documentIdInput = this.$searchTerm.parents('form').find('input[name="document_id"]')
- this.$editionIdInput = this.$searchTerm.parents('form').find('input[name="edition_id"]')
- this.$loaderIndicator = this.$searchTerm.siblings('img.js-loader')
- this.setupEventHandlers()
- },
-
- enterKeyPressed: function (event) {
- return event.which === 13
- },
-
- setupEventHandlers: function () {
- var $findButton = $('#find-documents')
- $findButton.click(function (event) { documentFinder.searchForDocument() })
- this.$searchTerm.keypress(function (event) {
- if (documentFinder.enterKeyPressed(event)) {
- event.preventDefault()
- $findButton.click()
- }
- })
- this.$searchTerm.keydown(function (event) {
- documentFinder.searchTermContent = $(this).val()
- })
- this.$searchTerm.keyup(function (event) {
- if (documentFinder.searchTermChanged()) {
- documentFinder.$searchTerm.autocomplete('disable')
- documentFinder.$documentIdInput.val('')
- documentFinder.$editionIdInput.val('')
- }
- })
- },
-
- searchTermChanged: function () {
- return this.$searchTerm.val() !== documentFinder.searchTermContent
- },
-
- searchForDocument: function () {
- var url = '/government/admin/document_searches.json'
- this.$loaderIndicator.show()
- $.ajax(url, {
- data: $.extend({ title: this.$searchTerm.val() }, this.additionalFilterParams),
- success: function (data, textStatus, xhr) {
- documentFinder.showSearchResults(data.results)
- },
- error: this.showErrorMessage,
- complete: function () {
- documentFinder.$loaderIndicator.hide()
- }
- })
- },
-
- showSearchResults: function (results) {
- this.latestResults = results
- var noResultsMessage = this.noResultsMessage
-
- var formatResults = function (data) {
- var results = []
- $.each(data, function (i, result) { results.push(result.title) })
- if (results.length) { return results } else { return [noResultsMessage] }
- }
-
- this.$searchTerm.autocomplete('option', 'source', formatResults(results))
- this.$searchTerm.autocomplete('enable')
- this.$searchTerm.autocomplete('search', '')
- },
-
- selectDocFromMenu: function (event, ui) {
- $.each(this.latestResults, function (i, result) {
- if (result.title === ui.item.label) {
- documentFinder.$documentIdInput.val(result.document_id).trigger('change')
- documentFinder.$editionIdInput.val(result.id).trigger('change')
- }
- })
- },
-
- showErrorMessage: function (jqXHR, textStatus, errorThrown) {
- alert("Sorry, we couldn't find any documents. " +
- 'The server said: ' + errorThrown)
- }
- }
- root.GOVUK.documentFinder = documentFinder
-}).call(this)
diff --git a/app/assets/javascripts/admin_legacy/views/statistics_announcements/statistics_announcement_linker.js b/app/assets/javascripts/admin_legacy/views/statistics_announcements/statistics_announcement_linker.js
deleted file mode 100644
index f1ec3506a88..00000000000
--- a/app/assets/javascripts/admin_legacy/views/statistics_announcements/statistics_announcement_linker.js
+++ /dev/null
@@ -1,47 +0,0 @@
-(function () {
- 'use strict'
- window.GOVUK = window.GOVUK || {}
-
- window.GOVUK.statisticsAnnouncementLinker = {
- init: function init () {
- var $linker = $('.js-document-announcement-linker')
- var $documentFinder = $('#document-finder')
- var $documentFinderResult = $documentFinder.find('#edition_id')
- var $annoucementForm = $('form.edit_statistics_announcement')
- var $publicationInput = $annoucementForm.find('input#statistics_announcement_publication_id')
-
- // Link to reveal document finder
- var $revealLink = $('')
- $revealLink.on('click', function () {
- $linker.hide()
- $documentFinder.show()
- $documentFinder.find('input#title').focus()
- })
-
- // insert the revealLink at the appropriate point with the appropriate
- // text depending on whether it's linking or changing an existing link
- if ($publicationInput.val() === '') {
- $revealLink.text('connect an existing draft')
- $linker.append(' or ').append($revealLink)
- } else {
- $revealLink.text('Change linked document')
- $linker.append('
').append($revealLink)
- }
-
- // add link to cancel document linking
- var $resetLink = $('cancel')
- $documentFinder.append(' or ').append($resetLink)
- $resetLink.on('click', function () {
- // hide the documentFinder
- $documentFinder.hide()
- $linker.show()
- })
-
- // listener to assign publication when a result is clicked on in the documentFinder
- $documentFinderResult.change(function () {
- $publicationInput.val($(this).val())
- $annoucementForm.submit()
- })
- }
- }
-}())
diff --git a/app/controllers/admin/document_searches_controller.rb b/app/controllers/admin/document_searches_controller.rb
deleted file mode 100644
index 832f32c7d64..00000000000
--- a/app/controllers/admin/document_searches_controller.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-class Admin::DocumentSearchesController < Admin::BaseController
- def show
- @editions = Filterer.new(params).editions.pluck(:id, :document_id, :title)
- end
-
- class Filterer
- attr_reader :params
-
- def initialize(params)
- @params = params
- end
-
- def editions
- filters_for(params).inject(edition_scope) do |editions, filter|
- filter.call(editions)
- end
- end
-
- def edition_scope
- Edition
- .with_translations(I18n.locale)
- .limit(10)
- end
-
- private
-
- def filters_for(params)
- filters = []
-
- if params[:title]
- filters << ->(editions) { editions.with_title_containing(params[:title]) }
- end
-
- type = find_type(params[:type])
- if type
- filters << ->(editions) { editions.by_type(type) }
-
- if params[:subtypes]
- filters << ->(editions) { editions.by_subtypes(type, params[:subtypes]) }
- end
- end
-
- filters << ->(editions) { editions.in_state(params[:state] || "active") }
-
- filters
- end
-
- def find_type(type_name)
- if type_name
- Whitehall.edition_classes.find do |klass|
- klass.to_s == type_name.classify
- end
- end
- end
- end
-end
diff --git a/app/helpers/admin/document_searches_helper.rb b/app/helpers/admin/document_searches_helper.rb
deleted file mode 100644
index 4072d3b3fca..00000000000
--- a/app/helpers/admin/document_searches_helper.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module Admin::DocumentSearchesHelper
- def public_time_for_edition(edition)
- if edition.public_timestamp.present?
- absolute_date(edition.public_timestamp)
- else
- "(#{edition.state.humanize})"
- end
- end
-end
diff --git a/app/views/admin/document_searches/show.json.jbuilder b/app/views/admin/document_searches/show.json.jbuilder
deleted file mode 100644
index 9eb56f5bb07..00000000000
--- a/app/views/admin/document_searches/show.json.jbuilder
+++ /dev/null
@@ -1,8 +0,0 @@
-json.results_any? @editions.any?
-json.set! :results do
- json.array! @editions do |id, document_id, title|
- json.id id
- json.document_id document_id
- json.title title
- end
-end
diff --git a/config/routes.rb b/config/routes.rb
index d77dd31cd11..ebf450af198 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -28,7 +28,6 @@ def redirect(path, options = { prefix: Whitehall.router_prefix })
end
resources :authors, only: [:show]
- resource :document_searches, only: [:show]
resources :document_collections, path: "collections", except: [:index] do
resources :document_collection_groups, as: :groups, path: "groups" do
diff --git a/test/functional/admin/document_searches_controller_test.rb b/test/functional/admin/document_searches_controller_test.rb
deleted file mode 100644
index 05f4e53a494..00000000000
--- a/test/functional/admin/document_searches_controller_test.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require "test_helper"
-
-class Admin::DocumentSearchesControllerTest < ActionController::TestCase
- should_be_an_admin_controller
-
- setup do
- login_as create(:writer)
- end
-
- def json_response
- JSON.parse(response.body)
- end
-
- view_test "GET #show returns filter results as JSON" do
- publication = create(:publication, title: "search term")
- get :show, params: { title: "search term" }, format: :json
- assert_response :success
- assert_equal true, json_response["results_any?"]
- assert_equal 1, json_response["results"].size
-
- publication_json = json_response["results"].first
- assert_equal publication.id, publication_json["id"]
- assert_equal publication.document_id, publication_json["document_id"]
- assert_equal publication.title, publication_json["title"]
- end
-
- view_test "GET #show can filter by edition type and subtype" do
- guidance = create(:publication, title: "search term", publication_type: PublicationType::Guidance)
- _form = create(:publication, title: "search term", publication_type: PublicationType::Form)
-
- get :show, params: { title: "search term", type: "publication", subtypes: [PublicationType::Guidance.id] }, format: :json
-
- assert_response :success
- assert_equal true, json_response["results_any?"]
- assert_equal 1, json_response["results"].size
-
- publication_json = json_response["results"].first
- assert_equal guidance.id, publication_json["id"]
- assert_equal guidance.document_id, publication_json["document_id"]
- assert_equal guidance.title, publication_json["title"]
- end
-end