1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-18 07:52:23 +01:00

[sso] save and restore field data mapping

This commit is contained in:
Sylvain 2016-09-15 15:58:21 +02:00
parent ee333df53f
commit 13f416a101
10 changed files with 38 additions and 8 deletions

View File

@ -85,7 +85,7 @@ class AuthenticationController
$scope.datatype = datatype $scope.datatype = datatype
## data transformation rules ## data transformation rules
$scope.transformation = $scope.transformation =
rules: {} #TODO get from resolve rules: field.transformation || {}
## available transformation formats ## available transformation formats
$scope.formats = $scope.formats =
date: [ date: [
@ -103,15 +103,22 @@ class AuthenticationController
} }
] ]
## Create a new mapping between anything and an expected integer
$scope.addIntegerMapping = ->
unless angular.isArray $scope.transformation.rules.mapping
$scope.transformation.rules.mapping = []
$scope.transformation.rules.mapping.push({from:'', to:0})
## close and save the modifications ## close and save the modifications
$scope.ok = -> $scope.ok = ->
console.log('TODO') $uibModalInstance.close($scope.transformation.rules)
$uibModalInstance.close()
## do not save the modifications ## do not save the modifications
$scope.cancel = -> $scope.cancel = ->
$uibModalInstance.dismiss() $uibModalInstance.dismiss()
] ]
.result['finally'](null).then (transfo_rules) ->
mapping.transformation = transfo_rules

View File

@ -125,6 +125,7 @@ p, .widget p {
.pull-in{margin-left: -15px;margin-right: -15px;} .pull-in{margin-left: -15px;margin-right: -15px;}
.pull-out{margin:-10px -15px;} .pull-out{margin:-10px -15px;}
.width-35 { width: 35% !important; }
.width-70 { width: 70%; } .width-70 { width: 70%; }
.b{border: 1px solid rgba(0, 0, 0, 0.05)} .b{border: 1px solid rgba(0, 0, 0, 0.05)}

View File

@ -35,10 +35,23 @@
ng-options="format.value as format.label for format in formats.date"> ng-options="format.value as format.label for format in formats.date">
</select> </select>
</div> </div>
<!-- INTEGER -->
<div ng-switch-when="integer">
<label for="add_mapping" translate>{{ 'mappings' }}</label>
<button class="btn btn-default pull-right" ng-click="addIntegerMapping()"><i class="fa fa-plus"></i></button>
<ul>
<li ng-repeat="map in transformation.rules.mapping" class="m-t-sm">
<input type="text" class="form-control inline width-35" ng-model="map.from">
<i class="fa fa-arrows-h"></i>
<input type="number" class="form-control inline width-35" ng-model="map.to">
</li>
</ul>
</div>
</ng-switch> </ng-switch>
</form> </form>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<!--<button class="btn btn-primary" ng-click="ok()" ng-disabled="!mappingForm.$valid" translate>{{ 'confirm' }}</button>--> <button class="btn btn-primary" ng-click="ok()" ng-disabled="!mappingForm.$valid" ng-if="datatype != 'string' && datatype != 'text'" translate>{{ 'confirm' }}</button>
<button class="btn btn-warning" ng-click="cancel()" translate>{{ 'cancel' }}</button> <button class="btn btn-warning" ng-click="cancel()" translate>{{ 'cancel' }}</button>
</div> </div>

View File

@ -58,7 +58,8 @@ class API::AuthProvidersController < API::ApiController
params.require(:auth_provider).permit(:name, :providable_type, providable_attributes: [ params.require(:auth_provider).permit(:name, :providable_type, providable_attributes: [
:id, :base_url, :token_endpoint, :authorization_endpoint, :profile_url, :client_id, :client_secret, :id, :base_url, :token_endpoint, :authorization_endpoint, :profile_url, :client_id, :client_secret,
o_auth2_mappings_attributes: [ o_auth2_mappings_attributes: [
:id, :local_model, :local_field, :api_field, :api_endpoint, :api_data_type, :_destroy :id, :local_model, :local_field, :api_field, :api_endpoint, :api_data_type, :_destroy,
transformation: [:format, :true_value, :false_value, mapping: [:from, :to]]
] ]
]) ])
end end

View File

@ -6,7 +6,7 @@ if @provider.providable_type == OAuth2Provider.name
json.providable_attributes do json.providable_attributes do
json.extract! @provider.providable, :id, :base_url, :token_endpoint, :authorization_endpoint, :profile_url, :client_id, :client_secret json.extract! @provider.providable, :id, :base_url, :token_endpoint, :authorization_endpoint, :profile_url, :client_id, :client_secret
json.o_auth2_mappings_attributes @provider.providable.o_auth2_mappings do |m| json.o_auth2_mappings_attributes @provider.providable.o_auth2_mappings do |m|
json.extract! m, :id, :local_model, :local_field, :api_field, :api_endpoint, :api_data_type json.extract! m, :id, :local_model, :local_field, :api_field, :api_endpoint, :api_data_type, :transformation
end end
end end
end end

View File

@ -251,6 +251,7 @@ en:
data_mapping: "Data mapping" data_mapping: "Data mapping"
expected_data_type: "Expected data type" expected_data_type: "Expected data type"
input_format: "Input format" input_format: "Input format"
mappings: "Mappings"
oauth2: oauth2:
# edition/creation form of an OAuth2 authentication provider # edition/creation form of an OAuth2 authentication provider

View File

@ -251,6 +251,7 @@ fr:
data_mapping: "Correspondance des données" data_mapping: "Correspondance des données"
expected_data_type: "Type de données attendues" expected_data_type: "Type de données attendues"
input_format: "Format d'entrée" input_format: "Format d'entrée"
mappings: "Correspondances"
oauth2: oauth2:
# formulaire d'édition/création d'un fournisseur d'authentification de type OAuth2 # formulaire d'édition/création d'un fournisseur d'authentification de type OAuth2

View File

@ -0,0 +1,5 @@
class AddTransformationToOAuth2Mapping < ActiveRecord::Migration
def change
add_column :o_auth2_mappings, :transformation, :jsonb
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160906145713) do ActiveRecord::Schema.define(version: 20160915105234) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -305,6 +305,7 @@ ActiveRecord::Schema.define(version: 20160906145713) do
t.string "local_model" t.string "local_model"
t.string "api_endpoint" t.string "api_endpoint"
t.string "api_data_type" t.string "api_data_type"
t.jsonb "transformation"
end end
add_index "o_auth2_mappings", ["o_auth2_provider_id"], name: "index_o_auth2_mappings_on_o_auth2_provider_id", using: :btree add_index "o_auth2_mappings", ["o_auth2_provider_id"], name: "index_o_auth2_mappings_on_o_auth2_provider_id", using: :btree