Skip to content

Commit

Permalink
v1.9.7
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjdk committed Dec 23, 2023
1 parent 99d522a commit ddfb4af
Show file tree
Hide file tree
Showing 14 changed files with 590 additions and 18 deletions.
9 changes: 9 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Changelog
*Below is the version history of [TrelloDotNet](https://github.com/rwjdk/TrelloDotNet) (An wrapper of the Trello API)*

## 1.9.7 (23rd of December 2023)
#### TrelloClient
- Added a set of handy Checklist Extensions on single and collection of checklists (`GetNumberOfItems`, `GetNumberOfCompletedItems`,`GetNumberOfIncompleteItems`, `IsAllComplete`,`IsAnyIncomplete`)
- Added advanced version of [`MoveCardToListAsync`](https://github.com/rwjdk/TrelloDotNet/wiki/MoveCardToListAsync) that accept additional options for the move (Position and NamedPosition)
- Added [`MoveCardToBoard`](https://github.com/rwjdk/TrelloDotNet/wiki/MoveCardToBoard)
- Added `GetMemberOption` overloads to the various member-get methods
- Added Member Properties `Email` and `MemberType`
- Added Properties on Member to the various Avatar URLs (30x30, 50x50, 170x170 pixels and the original image)

## 1.9.6 (22nd of December 2023)
#### General
- Better nuget description and tags
Expand Down
1 change: 1 addition & 0 deletions TrelloDotNet/TrelloDotNet.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/GrammarAndSpelling/GrammarChecking/Exceptions/=Id/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Emoji/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=prefs/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Trello/@EntryIndexedValue">True</s:Boolean>
Expand Down
2 changes: 1 addition & 1 deletion TrelloDotNet/TrelloDotNet/Model/Checklist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class Checklist
[JsonPropertyName("pos")]
[QueryParameter]
public decimal Position { get; set; }

/// <summary>
/// The items of the Checklist
/// </summary>
Expand Down
101 changes: 101 additions & 0 deletions TrelloDotNet/TrelloDotNet/Model/ChecklistExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using System.Collections.Generic;
using System.Linq;

namespace TrelloDotNet.Model
{
/// <summary>
/// A set of handy extension methods for Checklists
/// </summary>
public static class ChecklistExtensions
{
/// <summary>
/// Get Number of Items on the Checklist regardless of state
/// </summary>
/// <returns>Number of Items</returns>
public static int GetNumberOfItems(this Checklist checklist)
{
return checklist.Items.Count;
}

/// <summary>
/// Get the Number of Completed items on the Checklist
/// </summary>
/// <returns>Number of Completed Items</returns>
public static int GetNumberOfCompletedItems(this Checklist checklist)
{
return checklist.Items.Count(x => x.State == ChecklistItemState.Complete);
}

/// <summary>
/// Get the Number of Incomplete items on the Checklist
/// </summary>
/// <returns>Number of Completed Items</returns>
public static int GetNumberOfIncompleteItems(this Checklist checklist)
{
return checklist.Items.Count(x => x.State == ChecklistItemState.Incomplete);
}

/// <summary>
/// Returns if all items on the Checklist is complete
/// </summary>
/// <returns>True if all Items are complete</returns>
public static bool IsAllComplete(this Checklist checklist)
{
return checklist.Items.All(x => x.State == ChecklistItemState.Complete);
}

/// <summary>
/// Returns if any of the checklist items ar not yet complete
/// </summary>
/// <returns>True if on or more is incomplete</returns>
public static bool IsAnyIncomplete(this Checklist checklist)
{
return checklist.Items.Any(x => x.State != ChecklistItemState.Complete);
}

/// <summary>
/// Get Number of Items across a collection of Checklists regardless of state
/// </summary>
/// <returns>Number of Items</returns>
public static int GetNumberOfItems(this IEnumerable<Checklist> checklists)
{
return checklists.Sum(x => x.GetNumberOfItems());
}

/// <summary>
/// Get the Number of Completed items across a collection of Checklists
/// </summary>
/// <returns>Number of Completed Items</returns>
public static int GetNumberOfCompletedItems(this IEnumerable<Checklist> checklists)
{
return checklists.Sum(x => x.GetNumberOfCompletedItems());
}

/// <summary>
/// Get the Number of Incomplete items across a collection of Checklists
/// </summary>
/// <returns>Number of Completed Items</returns>
public static int GetNumberOfIncompleteItems(this IEnumerable<Checklist> checklists)
{
return checklists.Sum(x => x.GetNumberOfIncompleteItems());
}

/// <summary>
/// Returns if all items on the Checklist is complete
/// </summary>
/// <returns>True if all Items are complete</returns>
public static bool IsAllComplete(this IEnumerable<Checklist> checklists)
{
return checklists.All(x => x.IsAllComplete());
}

/// <summary>
/// Returns if any of the checklist items ar not yet complete
/// </summary>
/// <returns>True if on or more is incomplete</returns>
public static bool IsAnyIncomplete(this IEnumerable<Checklist> checklists)
{
return checklists.Any(x => x.IsAnyIncomplete());
}
}
}
38 changes: 37 additions & 1 deletion TrelloDotNet/TrelloDotNet/Model/Member.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Diagnostics;
using System.Text.Json.Serialization;
using TrelloDotNet.Control;

namespace TrelloDotNet.Model
{
Expand Down Expand Up @@ -38,19 +39,54 @@ public class Member
public string Initials { get; private set; }

/// <summary>
/// The url of this member's avatar
/// The base url of this member's avatar
/// </summary>
[JsonPropertyName("avatarUrl")]
[JsonInclude]
public string AvatarUrl { get; private set; }

/// <summary>
/// 30x30 Pixel version of the Members Avatar Image
/// </summary>
public string AvatarUrl30 => AvatarUrl != null ? $"{AvatarUrl}/30.png" : null;

/// <summary>
/// 50x50 Pixel version of the Members Avatar Image
/// </summary>
public string AvatarUrl50 => AvatarUrl != null ? $"{AvatarUrl}/50.png" : null;

/// <summary>
/// 170x170 Pixel version of the Members Avatar Image
/// </summary>
public string AvatarUrl170 => AvatarUrl != null ? $"{AvatarUrl}/170.png" : null;

/// <summary>
/// Original version of the Members Avatar Image
/// </summary>
public string AvatarUrlOriginal => AvatarUrl != null ? $"{AvatarUrl}/original.png" : null;

/// <summary>
/// Whether the user has confirmed their email address for their account.
/// </summary>
[JsonPropertyName("confirmed")]
[JsonInclude]
public bool Confirmed { get; private set; }

/// <summary>
/// The Email of the member (only populated if field is included in GetMemberOptions)
/// </summary>
[JsonPropertyName("email")]
[JsonInclude]
public string Email { get; private set; }

/// <summary>
/// The Type of the Members (admin, normal, observer) [only populated if field is included in GetMemberOptions]
/// </summary>
[JsonPropertyName("memberType")]
[JsonInclude]
[JsonConverter(typeof(EnumViaJsonPropertyConverter<MembershipType>))]
public MembershipType MemberType { get; private set; }

internal static Member CreateDummy()
{
return new Member()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Collections.Generic;

namespace TrelloDotNet.Model.Options.GetMemberOptions
{
/// <summary>
/// Options when retrieving members
/// </summary>
public class GetMemberOptions
{
/// <summary>
/// all or a comma-separated list of fields.
/// </summary>
public MemberFields MemberFields { get; set; }

internal QueryParameter[] GetParameters()
{
List<QueryParameter> parameters = new List<QueryParameter>();
if (MemberFields != null)
{
parameters.Add(new QueryParameter("fields", string.Join(",", MemberFields.Fields)));
}

return parameters.ToArray();
}
}
}
29 changes: 19 additions & 10 deletions TrelloDotNet/TrelloDotNet/Model/Options/MemberFieldsType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,36 @@ public enum MemberFieldsType
/// <summary>
/// The full name related to the account, if it is public.
/// </summary>
[JsonPropertyName("fullName")]
FullName,
[JsonPropertyName("fullName")] FullName,

/// <summary>
/// Username of the Member
/// </summary>
[JsonPropertyName("username")]
Username,
[JsonPropertyName("username")] Username,

/// <summary>
/// The initials related to the account, if it is public.
/// </summary>
[JsonPropertyName("initials")]
Initials,
[JsonPropertyName("initials")] Initials,

/// <summary>
/// The url of this member's avatar
/// </summary>
[JsonPropertyName("avatarUrl")]
AvatarUrl,
[JsonPropertyName("avatarUrl")] AvatarUrl,

/// <summary>
/// Whether the user has confirmed their email address for their account.
/// </summary>
[JsonPropertyName("confirmed")]
Confirmed,
[JsonPropertyName("confirmed")] Confirmed,

/// <summary>
/// Email of Member
/// </summary>
[JsonPropertyName("email")] Email,

/// <summary>
/// Type Member (admin, normal, observer)
/// </summary>
[JsonPropertyName("memberType")] MemberType,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace TrelloDotNet.Model.Options.MoveCardToBoardOptions
{
/// <summary>
/// Options when moving a card to a new board
/// </summary>
public class MoveCardToBoardOptions
{
/// <summary>
/// Id of a List on the new Board (if not specified card will be moved to the first list on the board)
/// </summary>
public string NewListId { get; set; }

/// <summary>
/// Position of the card on the new list (Will not be used if NamedPosition is used)
/// </summary>
public decimal? PositionOnNewList { get; set; }

/// <summary>
/// Named position of the card on the new list (will ignore position given in these options if any)
/// </summary>
public NamedPosition? NamedPositionOnNewList { get; set; }

/// <summary>
/// Define what should happen to Labels on the Card (Default = 'MigrateToLabelsOfSameNameAndColorAndCreateMissing')
/// </summary>
public MoveCardToBoardOptionsLabelOptions LabelOptions { get; set; } = MoveCardToBoardOptionsLabelOptions.MigrateToLabelsOfSameNameAndColorAndCreateMissing;

/// <summary>
/// Define what should happen to Members on the Card (Default = 'KeepMembersAlsoOnNewBoardAndRemoveRest')
/// </summary>
public MoveCardToBoardOptionsMemberOptions MemberOptions { get; set; } = MoveCardToBoardOptionsMemberOptions.KeepMembersAlsoOnNewBoardAndRemoveRest;

/// <summary>
/// If the Start Date of the Card should be removed (Default = False)
/// </summary>
public bool RemoveStartDate { get; set; }

/// <summary>
/// If the Due Date of the Card should be removed (Default = False)
/// </summary>
public bool RemoveDueDate { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace TrelloDotNet.Model.Options.MoveCardToBoardOptions
{
/// <summary>
/// Label options when moving a Card to another board
/// </summary>
public enum MoveCardToBoardOptionsLabelOptions
{
/// <summary>
/// Migrate Labels with the same color and name, and create those missing as labels on the new board
/// </summary>
MigrateToLabelsOfSameNameAndColorAndCreateMissing,

/// <summary>
/// Migrate Labels with the same color and name, and remove all labels that does not exist on the new board
/// </summary>
MigrateToLabelsOfSameNameAndColorAndRemoveMissing,

/// <summary>
/// Migrate Labels with the same name (allow color change), and create those missing as labels on the new board
/// </summary>
MigrateToLabelsOfSameNameAndCreateMissing,

/// <summary>
/// Migrate Labels with the same name (allow color change), and remove all labels that does not exist on the new board
/// </summary>
MigrateToLabelsOfSameNameAndRemoveMissing,

/// <summary>
/// Remove all labels before move to new board
/// </summary>
RemoveAllLabelsOnCard,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace TrelloDotNet.Model.Options.MoveCardToBoardOptions
{
/// <summary>
/// Member options when moving a Card to another board
/// </summary>
public enum MoveCardToBoardOptionsMemberOptions
{
/// <summary>
/// Keep the members on the card that is also members of the new board, and remove the rest
/// </summary>
KeepMembersAlsoOnNewBoardAndRemoveRest,

/// <summary>
/// Remove all members on the board
/// </summary>
RemoveAllMembersOnCard
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace TrelloDotNet.Model.Options.MoveCardToListOptions
{
/// <summary>
/// Option of the Move
/// </summary>
public class MoveCardToListOptions
{
/// <summary>
/// Position of the card on the new list (Will not be used if NamedPosition is used)
/// </summary>
public decimal? PositionOnNewList { get; set; }

/// <summary>
/// Named position of the card on the new list (will ignore position given in these options if any)
/// </summary>
public NamedPosition? NamedPositionOnNewList { get; set; }
}
}

0 comments on commit ddfb4af

Please sign in to comment.