Skip to content

Commit

Permalink
Rename widgetLayout to taskWidgetLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
ljdelight committed Oct 15, 2023
1 parent 11597d7 commit 9b465bb
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/org/maproulette/framework/model/Challenge.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@ 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 ~
checkin_source ~ overpassql ~ overpassTargetType ~ remoteGeoJson ~ status ~ statusMessage ~ defaultPriority ~ highPriorityRule ~
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
Expand Down Expand Up @@ -328,7 +328,7 @@ object ChallengeRepository {
taskBundleIdProperty,
isArchived,
reviewSetting,
widgetLayout,
taskWidgetLayout,
systemArchivedAt
),
status,
Expand Down
24 changes: 12 additions & 12 deletions app/org/maproulette/models/dal/ChallengeDAL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ~
Expand All @@ -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
Expand Down Expand Up @@ -189,7 +189,7 @@ class ChallengeDAL @Inject() (
taskBundleIdProperty,
isArchived,
reviewSetting,
widgetLayout
taskWidgetLayout
),
status,
statusMessage,
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -328,7 +328,7 @@ class ChallengeDAL @Inject() (
taskBundleIdProperty,
isArchived,
reviewSetting,
widgetLayout,
taskWidgetLayout,
systemArchivedAt,
presets
),
Expand Down Expand Up @@ -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},
Expand All @@ -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
Expand Down Expand Up @@ -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]]
Expand Down Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions conf/evolutions/default/93.sql
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 9b465bb

Please sign in to comment.