Skip to content

Commit

Permalink
Merge pull request #4 from sebastianconcept/crud
Browse files Browse the repository at this point in the history
Crud
  • Loading branch information
sebastianconcept authored Dec 26, 2023
2 parents 9a7af69 + dcf3363 commit d22ae9b
Show file tree
Hide file tree
Showing 9 changed files with 349 additions and 20 deletions.
12 changes: 11 additions & 1 deletion BaselineOfRide/BaselineOfRide.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ BaselineOfRide >> setUpDependencies: spec [
self zinc: spec.
self mustache: spec.
self teapot: spec.
self singularizePluralize: spec.

"In Ride-Pharo we install some general extensions
needed for Pharo, plus extensions for Zinc and Teapot."
Expand All @@ -81,13 +82,22 @@ BaselineOfRide >> setUpPackages: spec [
spec package: 'Ride' with: [
spec requires:
#( 'Mustache' 'ZincHTTPComponents' 'Teapot' 'JSON' 'Ride-Pharo'
'Mapless' ) ].
'Mapless' 'SingularizePluralize' ) ].

spec package: 'Ride-Tests' with: [ spec requires: #( 'Ride' ) ].
spec package: 'Ride-Examples' with: [ spec requires: #( 'Ride' ) ].
spec package: 'Ride-Tools' with: [ spec requires: #( 'Ride' ) ]
]

{ #category : #dependencies }
BaselineOfRide >> singularizePluralize: spec [

spec baseline: 'SingularizePluralize' with: [
spec
loads: #( 'SingularizePluralize' );
repository: 'github://pharo-contributions/SingularizePluralize:v1.1/src' ]
]

{ #category : #dependencies }
BaselineOfRide >> teapot: spec [

Expand Down
14 changes: 7 additions & 7 deletions Ride/RideCRUDHelper.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RideCRUDHelper class >> createMethodFor: aSymbol [
self redirectTo: #{2}_url notice: ''{1} was successfully created.''.
' format: {
aSymbol.
(self getPluralOf: aSymbol) }
aSymbol asLowercase asPlural asSnakeCase }
]

{ #category : #accessing }
Expand All @@ -42,7 +42,7 @@ RideCRUDHelper class >> destroyMethodFor: aSymbol [
notice: ''{1} was successfully destroyed.'' ] ]
' format: {
aSymbol.
(self getPluralOf: aSymbol) }
aSymbol asLowercase asPlural asSnakeCase }
]

{ #category : #accessing }
Expand All @@ -56,7 +56,7 @@ RideCRUDHelper class >> editMethodFor: aSymbol [
model := {1} findId: (self currentRequest uri segments reversed second) ]
' format: {
aSymbol.
(self getPluralOf: aSymbol) }
aSymbol asLowercase asPlural asSnakeCase }
]

{ #category : #accessing }
Expand All @@ -69,7 +69,7 @@ RideCRUDHelper class >> indexMethodFor: aSymbol [
model := {1} findAll
' format: {
aSymbol.
(self getPluralOf: aSymbol) }
aSymbol asLowercase asPlural asSnakeCase }
]

{ #category : #accessing }
Expand All @@ -82,7 +82,7 @@ RideCRUDHelper class >> newModelMethodFor: aSymbol [
model := {1} new
' format: {
aSymbol.
(self getPluralOf: aSymbol) }
aSymbol asLowercase asPlural asSnakeCase }
]

{ #category : #accessing }
Expand All @@ -96,7 +96,7 @@ RideCRUDHelper class >> showMethodFor: aSymbol [
model := {1} findId: (self currentRequest uri segments last) ]
' format: {
aSymbol.
(self getPluralOf: aSymbol) }
aSymbol asLowercase asPlural asSnakeCase }
]

{ #category : #accessing }
Expand All @@ -113,7 +113,7 @@ RideCRUDHelper class >> updateMethodFor: aSymbol [
self redirectTo: #{2}_url notice: ''{1} was successfully updated.''
' format: {
aSymbol.
(self getPluralOf: aSymbol) }
aSymbol asLowercase asPlural asSnakeCase }
]

{ #category : #actions }
Expand Down
7 changes: 0 additions & 7 deletions Ride/RideCompositeHelper.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ Class {
#category : #'Ride-Boilerplate'
}

{ #category : #'as yet unclassified' }
RideCompositeHelper class >> getPluralOf: aSymbol [

self flag: #todo.
^ aSymbol asSnakeCase
]

{ #category : #accessing }
RideCompositeHelper >> controllerForModel: aSymbol [

Expand Down
11 changes: 10 additions & 1 deletion Ride/RideMVCCRUDHelper.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,14 @@ RideMVCCRUDHelper >> for: aSymbol [
self
addCRUDMethodsTo: (self controllerForModel: aSymbol)
for: aSymbol.
self mustacheTemplateFor: aSymbol

doer view mustache
js: js;
crudIndexFor: aSymbol;
crudModelFor: aSymbol;
crudShowFor: aSymbol;
crudNewModelFor: aSymbol;
crudEditFor: aSymbol;
crudFormFor: aSymbol;
yourself
]
10 changes: 9 additions & 1 deletion Ride/RideMVPCRUDHelper.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,13 @@ RideMVPCRUDHelper >> for: aSymbol [
super for: aSymbol.
doer presenter for: aSymbol.
self addCRUDMethodsTo: (self presenterForModel: aSymbol) for: aSymbol.
self mustacheTemplateFor: aSymbol
doer view mustache
js: js;
crudIndexFor: aSymbol;
crudModelFor: aSymbol;
crudShowFor: aSymbol;
crudNewModelFor: aSymbol;
crudEditFor: aSymbol;
crudFormFor: aSymbol;
yourself
]
14 changes: 14 additions & 0 deletions Ride/RideMaplessModel.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"
I'm the abstract class for Mapless based Ride models
"
Class {
#name : #RideMaplessModel,
#superclass : #Mapless,
#category : #'Ride-Models'
}

{ #category : #converting }
RideMaplessModel >> asTemplateModel [

^ { (#name -> self class name) } asDictionary
]
10 changes: 8 additions & 2 deletions Ride/RideModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ I'm the abstract class of the models in Ride applications
"
Class {
#name : #RideModel,
#superclass : #Object,
#superclass : #Mapless,
#category : #'Ride-Models'
}

{ #category : #querying }
RideModel class >> findId: anId [

^ Ride repository find: self atId: anId
^ self getRepository find: self atId: anId
]

{ #category : #querying }
RideModel class >> getRepository [

^ Ride service repository
]

{ #category : #converting }
Expand Down
Loading

0 comments on commit d22ae9b

Please sign in to comment.