* @brief Returns widget refs for a single workspace. */
| 746 | * @brief Returns widget refs for a single workspace. |
| 747 | */ |
| 748 | API::CommandResponse API::Handlers::WorkspacesHandler::get(const QString& id, |
| 749 | const QJsonObject& params) |
| 750 | { |
| 751 | if (!params.contains(QStringLiteral("id"))) |
| 752 | return CommandResponse::makeError( |
| 753 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: id")); |
| 754 | |
| 755 | const int wid = params.value(QStringLiteral("id")).toInt(); |
| 756 | |
| 757 | const auto& workspaces = DataModel::ProjectModel::instance().activeWorkspaces(); |
| 758 | const auto it = findWorkspace(workspaces, wid); |
| 759 | if (it == workspaces.end()) |
| 760 | return CommandResponse::makeError( |
| 761 | id, ErrorCode::InvalidParam, QStringLiteral("Workspace not found: %1").arg(wid)); |
| 762 | |
| 763 | QJsonObject result; |
| 764 | result[QStringLiteral("id")] = it->workspaceId; |
| 765 | result[QStringLiteral("title")] = it->title; |
| 766 | result[QStringLiteral("icon")] = it->icon; |
| 767 | result[QStringLiteral("description")] = it->description; |
| 768 | result[QStringLiteral("widgets")] = refsToJson(it->workspaceId, it->widgetRefs); |
| 769 | return CommandResponse::makeSuccess(id, result); |
| 770 | } |
| 771 | |
| 772 | //-------------------------------------------------------------------------------------------------- |
| 773 | // Mutations |
nothing calls this directly
no test coverage detected