Skip to content

Commit

Permalink
fix(Schematics): Make variable naming consistent for entity blueprint (
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts authored and MikeRyanDev committed Jan 13, 2018
1 parent 1ecd658 commit 765b15a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@ export enum <%= classify(name) %>ActionTypes {
export class Load<%= classify(name) %>s implements Action {
readonly type = <%= classify(name) %>ActionTypes.Load<%= classify(name) %>s;

constructor(public payload: { <%= lowercase(name) %>s: <%= classify(name) %>[] }) {}
constructor(public payload: { <%= camelize(name) %>s: <%= classify(name) %>[] }) {}
}

export class Add<%= classify(name) %> implements Action {
readonly type = <%= classify(name) %>ActionTypes.Add<%= classify(name) %>;

constructor(public payload: { <%= lowercase(name) %>: <%= classify(name) %> }) {}
constructor(public payload: { <%= camelize(name) %>: <%= classify(name) %> }) {}
}

export class Add<%= classify(name) %>s implements Action {
readonly type = <%= classify(name) %>ActionTypes.Add<%= classify(name) %>s;

constructor(public payload: { <%= lowercase(name) %>s: <%= classify(name) %>[] }) {}
constructor(public payload: { <%= camelize(name) %>s: <%= classify(name) %>[] }) {}
}

export class Update<%= classify(name) %> implements Action {
readonly type = <%= classify(name) %>ActionTypes.Update<%= classify(name) %>;

constructor(public payload: { <%= lowercase(name) %>: Update<<%= classify(name) %>> }) {}
constructor(public payload: { <%= camelize(name) %>: Update<<%= classify(name) %>> }) {}
}

export class Update<%= classify(name) %>s implements Action {
readonly type = <%= classify(name) %>ActionTypes.Update<%= classify(name) %>s;

constructor(public payload: { <%= lowercase(name) %>s: Update<<%= classify(name) %>>[] }) {}
constructor(public payload: { <%= camelize(name) %>s: Update<<%= classify(name) %>>[] }) {}
}

export class Delete<%= classify(name) %> implements Action {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ export function reducer(
): State {
switch (action.type) {
case <%= classify(name) %>ActionTypes.Add<%= classify(name) %>: {
return adapter.addOne(action.payload.<%= lowercase(classify(name)) %>, state);
return adapter.addOne(action.payload.<%= camelize(name) %>, state);
}

case <%= classify(name) %>ActionTypes.Add<%= classify(name) %>s: {
return adapter.addMany(action.payload.<%= lowercase(classify(name)) %>s, state);
return adapter.addMany(action.payload.<%= camelize(name) %>s, state);
}

case <%= classify(name) %>ActionTypes.Update<%= classify(name) %>: {
return adapter.updateOne(action.payload.<%= lowercase(classify(name)) %>, state);
return adapter.updateOne(action.payload.<%= camelize(name) %>, state);
}

case <%= classify(name) %>ActionTypes.Update<%= classify(name) %>s: {
return adapter.updateMany(action.payload.<%= lowercase(classify(name)) %>s, state);
return adapter.updateMany(action.payload.<%= camelize(name) %>s, state);
}

case <%= classify(name) %>ActionTypes.Delete<%= classify(name) %>: {
Expand All @@ -42,7 +42,7 @@ export function reducer(
}

case <%= classify(name) %>ActionTypes.Load<%= classify(name) %>s: {
return adapter.addAll(action.payload.<%= lowercase(classify(name)) %>s, state);
return adapter.addAll(action.payload.<%= camelize(name) %>s, state);
}

case <%= classify(name) %>ActionTypes.Clear<%= classify(name) %>s: {
Expand Down
4 changes: 2 additions & 2 deletions modules/schematics/src/entity/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default function(options: EntityOptions): Rule {
]);

return chain([
addReducerToState({ ...options, flat: true }),
addReducerImportToNgModule({ ...options, flat: true }),
addReducerToState({ ...options }),
addReducerImportToNgModule({ ...options }),
branchAndMerge(chain([mergeWith(templateSource)])),
])(host, context);
};
Expand Down

0 comments on commit 765b15a

Please sign in to comment.