From 9b465bb1852fa2a9b76160f33a512237e680b0c3 Mon Sep 17 00:00:00 2001 From: Lucas Burson Date: Sun, 15 Oct 2023 18:39:37 -0500 Subject: [PATCH] Rename widgetLayout to taskWidgetLayout --- .../controllers/api/ChallengeController.scala | 2 +- .../graphql/schemas/MRSchemaTypes.scala | 8 +++++-- .../framework/model/Challenge.scala | 2 +- .../repository/ChallengeRepository.scala | 6 ++--- .../maproulette/models/dal/ChallengeDAL.scala | 24 +++++++++---------- conf/evolutions/default/93.sql | 8 +++---- 6 files changed, 27 insertions(+), 23 deletions(-) diff --git a/app/org/maproulette/controllers/api/ChallengeController.scala b/app/org/maproulette/controllers/api/ChallengeController.scala index e9f663e8..6a906c08 100644 --- a/app/org/maproulette/controllers/api/ChallengeController.scala +++ b/app/org/maproulette/controllers/api/ChallengeController.scala @@ -1167,7 +1167,7 @@ class ChallengeController @Inject() ( Utils.insertIntoJson(jsonBody, "reviewSetting", Challenge.REVIEW_SETTING_NOT_REQUIRED)( IntWrites ) - jsonBody = Utils.insertIntoJson(jsonBody, "widgetLayout", "")(StringWrites) + jsonBody = Utils.insertIntoJson(jsonBody, "taskWidgetLayout", "")(StringWrites) jsonBody = Utils.insertIntoJson(jsonBody, "updateTasks", false)(BooleanWrites) jsonBody = Utils.insertIntoJson(jsonBody, "changesetUrl", false)(BooleanWrites) // if we can't find the parent ID, just use the user's default project instead diff --git a/app/org/maproulette/framework/graphql/schemas/MRSchemaTypes.scala b/app/org/maproulette/framework/graphql/schemas/MRSchemaTypes.scala index c2e394db..49b79245 100644 --- a/app/org/maproulette/framework/graphql/schemas/MRSchemaTypes.scala +++ b/app/org/maproulette/framework/graphql/schemas/MRSchemaTypes.scala @@ -173,8 +173,12 @@ trait MRSchemaTypes { deriveObjectType[Unit, ChallengeExtra]( ObjectTypeName("ChallengeExtra"), ReplaceField( - "widgetLayout", - Field("widgetLayout", StringType, resolve = _.value.widgetLayout.getOrElse("").toString) + "taskWidgetLayout", + Field( + "taskWidgetLayout", + StringType, + resolve = _.value.taskWidgetLayout.getOrElse("").toString + ) ) ) // Comment Types diff --git a/app/org/maproulette/framework/model/Challenge.scala b/app/org/maproulette/framework/model/Challenge.scala index a4cdcfad..0b74fe66 100644 --- a/app/org/maproulette/framework/model/Challenge.scala +++ b/app/org/maproulette/framework/model/Challenge.scala @@ -135,7 +135,7 @@ case class ChallengeExtra( taskBundleIdProperty: Option[String] = None, isArchived: Boolean = false, reviewSetting: Int = Challenge.REVIEW_SETTING_NOT_REQUIRED, - widgetLayout: Option[JsValue] = None, + taskWidgetLayout: Option[JsValue] = None, systemArchivedAt: Option[DateTime] = None, presets: Option[List[String]] = None ) extends DefaultWrites diff --git a/app/org/maproulette/framework/repository/ChallengeRepository.scala b/app/org/maproulette/framework/repository/ChallengeRepository.scala index 93c62669..55e5c590 100644 --- a/app/org/maproulette/framework/repository/ChallengeRepository.scala +++ b/app/org/maproulette/framework/repository/ChallengeRepository.scala @@ -263,7 +263,7 @@ object ChallengeRepository { get[Option[List[Long]]]("virtual_parent_ids") ~ get[Boolean]("challenges.is_archived") ~ get[Int]("challenges.review_setting") ~ - get[Option[JsValue]]("challenges.widget_layout") ~ + get[Option[JsValue]]("challenges.task_widget_layout") ~ get[Option[DateTime]]("challenges.system_archived_at") map { case id ~ name ~ created ~ modified ~ description ~ infoLink ~ ownerId ~ parentId ~ instruction ~ difficulty ~ blurb ~ enabled ~ featured ~ cooperativeType ~ popularity ~ checkin_comment ~ @@ -271,7 +271,7 @@ object ChallengeRepository { mediumPriorityRule ~ lowPriorityRule ~ defaultZoom ~ minZoom ~ maxZoom ~ defaultBasemap ~ defaultBasemapId ~ customBasemap ~ updateTasks ~ exportableProperties ~ osmIdProperty ~ taskBundleIdProperty ~ preferredTags ~ preferredReviewTags ~ limitTags ~ limitReviewTags ~ taskStyles ~ lastTaskRefresh ~ dataOriginDate ~ requiresLocal ~ location ~ bounding ~ - deleted ~ virtualParents ~ isArchived ~ reviewSetting ~ widgetLayout ~ systemArchivedAt => + deleted ~ virtualParents ~ isArchived ~ reviewSetting ~ taskWidgetLayout ~ systemArchivedAt => val hpr = highPriorityRule match { case Some(c) if StringUtils.isEmpty(c) || StringUtils.equals(c, "{}") => None case r => r @@ -328,7 +328,7 @@ object ChallengeRepository { taskBundleIdProperty, isArchived, reviewSetting, - widgetLayout, + taskWidgetLayout, systemArchivedAt ), status, diff --git a/app/org/maproulette/models/dal/ChallengeDAL.scala b/app/org/maproulette/models/dal/ChallengeDAL.scala index 7b517a8e..82f14db9 100644 --- a/app/org/maproulette/models/dal/ChallengeDAL.scala +++ b/app/org/maproulette/models/dal/ChallengeDAL.scala @@ -122,7 +122,7 @@ class ChallengeDAL @Inject() ( get[Boolean]("deleted") ~ get[Boolean]("challenges.is_archived") ~ get[Int]("challenges.review_setting") ~ - get[Option[JsValue]]("challenges.widget_layout") ~ + get[Option[JsValue]]("challenges.task_widget_layout") ~ get[Option[Int]]("challenges.completion_percentage") ~ get[Option[Int]]("challenges.tasks_remaining") map { case id ~ name ~ created ~ modified ~ description ~ infoLink ~ ownerId ~ parentId ~ instruction ~ @@ -132,7 +132,7 @@ class ChallengeDAL @Inject() ( minZoom ~ maxZoom ~ defaultBasemap ~ defaultBasemapId ~ customBasemap ~ updateTasks ~ exportableProperties ~ osmIdProperty ~ taskBundleIdProperty ~ preferredTags ~ preferredReviewTags ~ limitTags ~ limitReviewTags ~ taskStyles ~ lastTaskRefresh ~ dataOriginDate ~ location ~ bounding ~ - requiresLocal ~ deleted ~ isArchived ~ reviewSetting ~ widgetLayout ~ completionPercentage ~ tasksRemaining => + requiresLocal ~ deleted ~ isArchived ~ reviewSetting ~ taskWidgetLayout ~ completionPercentage ~ tasksRemaining => val hpr = highPriorityRule match { case Some(c) if StringUtils.isEmpty(c) || StringUtils.equals(c, "{}") => None case r => r @@ -189,7 +189,7 @@ class ChallengeDAL @Inject() ( taskBundleIdProperty, isArchived, reviewSetting, - widgetLayout + taskWidgetLayout ), status, statusMessage, @@ -259,7 +259,7 @@ class ChallengeDAL @Inject() ( get[Option[List[String]]]("presets") ~ get[Boolean]("challenges.is_archived") ~ get[Int]("challenges.review_setting") ~ - get[Option[JsValue]]("challenges.widget_layout") ~ + get[Option[JsValue]]("challenges.task_widget_layout") ~ get[Option[DateTime]]("challenges.system_archived_at") ~ get[Option[Int]]("challenges.completion_percentage") ~ get[Option[Int]]("challenges.tasks_remaining") map { @@ -271,7 +271,7 @@ class ChallengeDAL @Inject() ( customBasemap ~ updateTasks ~ exportableProperties ~ osmIdProperty ~ taskBundleIdProperty ~ preferredTags ~ preferredReviewTags ~ limitTags ~ limitReviewTags ~ taskStyles ~ lastTaskRefresh ~ dataOriginDate ~ location ~ bounding ~ requiresLocal ~ deleted ~ virtualParents ~ - presets ~ isArchived ~ reviewSetting ~ widgetLayout ~ systemArchivedAt ~ completionPercentage ~ tasksRemaining => + presets ~ isArchived ~ reviewSetting ~ taskWidgetLayout ~ systemArchivedAt ~ completionPercentage ~ tasksRemaining => val hpr = highPriorityRule match { case Some(c) if StringUtils.isEmpty(c) || StringUtils.equals(c, "{}") => None case r => r @@ -328,7 +328,7 @@ class ChallengeDAL @Inject() ( taskBundleIdProperty, isArchived, reviewSetting, - widgetLayout, + taskWidgetLayout, systemArchivedAt, presets ), @@ -481,7 +481,7 @@ class ChallengeDAL @Inject() ( medium_priority_rule, low_priority_rule, default_zoom, min_zoom, max_zoom, default_basemap, default_basemap_id, custom_basemap, updatetasks, exportable_properties, osm_id_property, task_bundle_id_property, last_task_refresh, data_origin_date, preferred_tags, preferred_review_tags, - limit_tags, limit_review_tags, task_styles, requires_local, is_archived, review_setting, widget_layout) + limit_tags, limit_review_tags, task_styles, requires_local, is_archived, review_setting, task_widget_layout) VALUES (${challenge.name}, ${challenge.general.owner}, ${challenge.general.parent}, ${challenge.general.difficulty}, ${challenge.description}, ${challenge.infoLink}, ${challenge.general.blurb}, ${challenge.general.instruction}, ${challenge.general.enabled}, ${challenge.general.featured}, @@ -496,7 +496,7 @@ class ChallengeDAL @Inject() ( ${challenge.extra.preferredTags}, ${challenge.extra.preferredReviewTags}, ${challenge.extra.limitTags}, ${challenge.extra.limitReviewTags}, ${challenge.extra.taskStyles}, ${challenge.general.requiresLocal}, ${challenge.extra.isArchived}, ${challenge.extra.reviewSetting}, - ${asJson(challenge.extra.widgetLayout.getOrElse(Json.parse("{}")))} + ${asJson(challenge.extra.taskWidgetLayout.getOrElse(Json.parse("{}")))} ) ON CONFLICT(parent_id, LOWER(name)) DO NOTHING RETURNING #${this.retrieveColumns}""" .as(this.parser.*) .headOption @@ -683,9 +683,9 @@ class ChallengeDAL @Inject() ( .asOpt[Int] .getOrElse(cachedItem.extra.reviewSetting) - val widgetLayout = (updates \ "widgetLayout") + val taskWidgetLayout = (updates \ "taskWidgetLayout") .asOpt[JsValue] - .getOrElse(cachedItem.extra.widgetLayout.getOrElse(Json.parse("{}"))) + .getOrElse(cachedItem.extra.taskWidgetLayout.getOrElse(Json.parse("{}"))) val presets: List[String] = (updates \ "presets") .asOpt[List[String]] @@ -716,8 +716,8 @@ class ChallengeDAL @Inject() ( custom_basemap = $customBasemap, updatetasks = $updateTasks, exportable_properties = $exportableProperties, osm_id_property = $osmIdProperty, task_bundle_id_property = $taskBundleIdProperty, preferred_tags = $preferredTags, preferred_review_tags = $preferredReviewTags, limit_tags = $limitTags, limit_review_tags = $limitReviewTags, task_styles = $taskStyles, - requires_local = $requiresLocal, is_archived = $isArchived, review_setting = $reviewSetting, widget_layout = ${asJson( - widgetLayout + requires_local = $requiresLocal, is_archived = $isArchived, review_setting = $reviewSetting, task_widget_layout = ${asJson( + taskWidgetLayout )} WHERE id = $id RETURNING #${this.retrieveColumns}""".as(parser.*).headOption diff --git a/conf/evolutions/default/93.sql b/conf/evolutions/default/93.sql index 2d48f326..5bbd3876 100644 --- a/conf/evolutions/default/93.sql +++ b/conf/evolutions/default/93.sql @@ -1,10 +1,10 @@ -- --- !Ups ALTER TABLE IF EXISTS challenges - ADD COLUMN widget_layout jsonb NOT NULL DEFAULT '{}'::jsonb; + ADD COLUMN task_widget_layout jsonb NOT NULL DEFAULT '{}'::jsonb; -COMMENT ON COLUMN challenges.widget_layout IS - 'The challenges.widget_layout is a json body that the GUI uses as a "suggested layout" when displaying the challenge to editors.'; +COMMENT ON COLUMN challenges.task_widget_layout IS + 'The challenges.task_widget_layout is json that the GUI uses as a "suggested layout" when displaying the Task Completion page.'; -- --- !Downs ALTER TABLE IF EXISTS challenges -DROP COLUMN widget_layout; +DROP COLUMN task_widget_layout;