Skip to content

Commit

Permalink
Merge pull request #38 from vigoren/develop
Browse files Browse the repository at this point in the history
Bug Fixes & QoL Improvements
  • Loading branch information
vigoren authored Mar 6, 2021
2 parents e7e2b11 + fd6e4e3 commit d684b8a
Show file tree
Hide file tree
Showing 22 changed files with 1,271 additions and 202 deletions.
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
# Change Log

## v1.1.6 - Bug Fixes & QoL Improvements

### Bug Fixes
- Fixed an issue when editing an existing note and being unable to change when it repeats.
- When Adding a new note or editing an existing note, the title field is now the initial field in focus instead of the details section.
- The default title for new notes is now empty instead of "New Note".
- Moved the "Note Default Player Visibility" setting to be under the Calendars General Settings instead of module settings under the game.
- Cleaned up the Calendar styling.
- Misc improvements to back end code.

### QoL Improvements

#### Macro Support

A function has been added to allow users to make macros that open the calendar.

This function can be accessed by using a script macro and running this command:

```javascript
SimpleCalendar.show();
```
**Important**: If this macro is intended to be useable by players don't forget to configure the Macros permissions for all players. It will need to be set to at least the "Limited", permission level.

The show function can take 3 parameters to set the year, month and day that the calendar opens up to.

Parameter|Type|Default|Details
---------|----|-------|-------
Year | number or null | null | The year to open the calendar too. If null is passed in it will open the calendar to the year the user last viewed
Month | number or null | null | The month to open the calendar too.<br/>This month is expected to start at 0, or be the index of the month to show. This way intercalary months can be easily chosen by using their index as they don't have a month number.<br/>-1 can be passed in to view the last month of the year.<br/>If null is passed in the calendar will open to the month the user last viewed.
Day | number or null | null | The day of the month to select.<br/>The day is expected to start at 1.<br/>-1 can be passed in to select the last day of the month.<br/>If null is passed in the selected day will be the last day the user selected, if any.

##### Examples
All these examples assume we are using a standard Gregorian calendar.

Open the calendar to August 2003
```javascript
SimpleCalendar.show(2003, 7);
```

Open the calendar to December 1999 and select the 25th day
```javascript
SimpleCalendar.show(1999, 11, 25);
```

## v1.1.0 - Reoccurring Notes, Leap Years, Intercalary Months and Bug Fixes

### Reoccurring Notes
Expand Down
46 changes: 40 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ Configuration of the calendar is straight forward. As the GM open the configurat

This tab allows you to set some general settings for the entire calendar.

Right now the only setting is to choose from a list of predefined calendars to get yours started with. The following calendars can be selected to configure the game calendar:
#### Predefined Calendars

This setting lets you choose from a list of predefined calendars to get your calendar started with. The following calendars can be selected to configure the game calendar:

Calendar|Description|Initial Date
--------|-----------|-------------
Expand All @@ -131,6 +133,15 @@ Warhammer | This is the calendar used by the Imperium in the Fantasy Warhammer g

All of these calendars can be further customized after they are loaded. They are here to provide a simple starting point for your game.

#### Other Settings

These are the other settings availible under the General Settings tab

Setting | Description
-------- | ----------
Note Default Player Visibility | For new notes, if by default the player visibility option is checked or not.


### Year Settings

This tab allows you to change some settings about the years in your game world
Expand Down Expand Up @@ -179,10 +190,33 @@ Months List | **This only appears if the Custom or Gregorian leap year rule is s

After you have changed the settings to your liking don't forget to save the configuration by hitting the Save Configuration button!

## Module Settings
## Macro's

The module has the following settings that can be adjusted in Foundry's game settings under the module settings tab.
You can create macros that will open up the Simple Calendar interface when used. To start create a new script macro and enter this as the command:

Setting | Description
-------- | ----------
Note Default Player Visibility | For new notes, if by default the player visibility option is checked or not.
```javascript
SimpleCalendar.show();
```

**Important**: If this macro is intended to be useable by players don't forget to configure the Macros permissions for all players. It will need to be set to at least the "Limited", permission level.

The show function can take 3 parameters to set the year, month and day that the calendar opens up to.

Parameter|Type|Default|Details
---------|----|-------|-------
Year | number or null | null | The year to open the calendar too. If null is passed in it will open the calendar to the year the user last viewed
Month | number or null | null | The month to open the calendar too.<br/>The month is expected to start at 0, or be the index of the month to show. This way intercalary months can be easily chosen by using their index as they don't have a month number.<br/>-1 can be passed in to view the last month of the year.<br/>If null is passed in the calendar will open to the month the user last viewed.
Day | number or null | null | The day of the month to select.<br/>The day is expected to start at 1.<br/>-1 can be passed in to select the last day of the month.<br/>If null is passed in the selected day will be the last day the user selected, if any.

### Examples
All these examples assume we are using a standard Gregorian calendar.

Open the calendar to August 2003
```javascript
SimpleCalendar.show(2003, 7);
```

Open the calendar to December 1999 and select the 25th day
```javascript
SimpleCalendar.show(1999, 11, 25);
```
9 changes: 2 additions & 7 deletions __mocks__/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,21 @@
*/
import {SettingNames} from "../src/constants";

// @ts-ignore
//@ts-ignore
const local: Localization = {
lang: '',
translations: {},
initialize: jest.fn(() => {return Promise.resolve();}),
localize: jest.fn((stringId: string) => {return '';}),
format: jest.fn((stringId: string, replacements: any) => {return '';}),
setLanguage: jest.fn((lang: string) => {return Promise.resolve();}),
_discoverLanguages: jest.fn(() => {}),
_getTranslations: jest.fn((lang: string) => {return Promise.resolve();}),
_loadTranslationFile: jest.fn((src: string) => {return Promise.resolve();})
setLanguage: jest.fn((lang: string) => {return Promise.resolve();})
};

// @ts-ignore
const user: User = {
name: '',
id: '',
active: true,
targets: new Set(),
viewedScene: '',
avatar: '',
//character: {},
Expand All @@ -34,7 +30,6 @@ const user: User = {
hasRole: jest.fn((role: string) => {return false;}),
isRole: jest.fn((role: string) => {return false;}),
setPermission: jest.fn((premission: string, allowed: boolean) => {}),
broadCastActivity: jest.fn((activityData?: UserActivityData) => {}),
assignHotbarMacro: jest.fn((macro: Macro | null, slot: number, {fromSlot}: { fromSlot?: number }): Promise<User> => { return Promise.resolve(user);}),
getHotbarMacros: jest.fn((page?: number): Macro[] => {return [];})
};
Expand Down
4 changes: 4 additions & 0 deletions __mocks__/merge-object.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const mergeO = jest.fn(()=>{return {target: {offsetHeight: 0}};});

// @ts-ignore
global.mergeObject = mergeO;
16 changes: 16 additions & 0 deletions __mocks__/text-editor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


class TE {
changeResult: any = null;

create () {
return Promise.resolve({on: this.on.bind(this)});
}

on(a: string, b: Function){
this.changeResult = b;
}
}

//@ts-ignore
global.TextEditor = new TE();
Loading

0 comments on commit d684b8a

Please sign in to comment.