设计建议:多用户多设备提交网站 [英] Design Advice: Multi-User Multi-Device Submission Site

查看:138
本文介绍了设计建议:多用户多设备提交网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:这是上一个问题

我正在对一个网站进行全面重新设计,允许用户为多个用户检查多台机器。

I'm working on complete redesign of a site that allows users to check out multiple machines for multiple users.

这里是我到目前为止。

输出两个cfqueries的首页。

A front page that outputs two cfqueries.

一个查询是活动计算机(即已检出)它是一个基本的cfoutput查询,并根据查询的值显示信息。我使用cfif语句过滤只有活动的机器(值= 1如果在SQL中活动)

One query is the active machines (ie, already checked out) It's a basic cfoutput query and displays the info based on the values of the query. I use a cfif statement to filter only the active machines (value = 1 if active in SQL)

它还输出像MAC,IP操作系统等

It also outputs stuff like MAC, IP OS etc.

另一个查询是用户可以检出的非活动计算机。它也基于它是否活动来过滤,这次由cfif query.active eq 0进行过滤。此查询具有几个表单字段,以便用户可以检查要检入的设备的复选框,在require字段中输入userID基本上)和提交。

The other query is the inactive machines that a user can check out. It is also filtered based on whether it is active, this time by cfif query.active eq 0. This query has a few form fields so that the user can check the check boxes of devices to check in, enter in the require fields (userID and comments, basically) and submit it.

在此页面底部有一个下拉菜单,允许您选择操作,表单通过操作number(form.choose_action)告诉cfc应该做什么。 IE如果动作号是4,这告诉cfc发送人到编辑页面并传递deviceID和它。

There is a dropdown menu at the bottom of this page that allows you to select the action, and the form passes in an action number (form.choose_action) that tells the cfc what it should do. IE if the action number is 4, that tells the cfc to send the person to the edit page and passes the deviceID along with it.

所以基本上我传入在每种情况下的DeviceID,以及仅当机器处于活动状态时的UserID。

So basically I'm passing in the DeviceID in every situation, and the UserID only if the machine is active.

当用户点击提交时,它会直接进入一个调用cfc的页面,该页面会执行大部分繁重工作。

When the user clicks submit, it goes straight to a page which calls a cfc that does most of the heavy lifting.

总而言之,这是一个极差的解决方案,因为它只有在一台机器一次进出时才真正工作得很好。

All in all, this is an extremely poor solution, as it only really works well when one machine is being checked in or out at a time.

这里有一张照片,可以更好地解释发生了什么。

Here's a picture to better explain what's going on.

这里是我想要的:

可以选择多个设备并签入/签出,希望以某种方式使用复选框。

Multiple devices can be selected and be checked in/checked out, hopefully using checkboxes in some way.

如果为用户检查计算机,UserID必须以某种方式附加到条目表单中的相应设备(非活动输出查询),并且应与在单个插入中的deviceID,如果可能的话。

If checking a machine out for a user, UserIDs have to be somehow attached to the respective devices in the entry form (the inactive output query) and should be entered along with the deviceID in a single insert, if possible.

我想要能够检入多个设备,但也阻止人们检查活动的计算机(因为他们已经签出)。对于非活动计算机也是如此,我想阻止用户检入尚未检出的计算机。现在我只是使用数字(即如果字段大于0)

I want to be able to check in multiple devices, but also stop people from checking out machines that are active (as they are already checked out). Same goes for inactive machines, I would like to stop a user from checking in a machine that has yet to be checked out. As of now I'm just using number (ie if field is greater than 0 )

一些注释:一次只有一个用户使用这个,我不必担心会话内容或有很多人试图签入同一个设备。

Some notes: Only one user is going to be using this at a time, so I don't have to worry about session stuff or having lots of people trying to check in the same device.

目前,我目前将变量推送到一个页面,然后将表单数据传递到CFC中,这可能不是最好的方式。

At the moment I currently push variables to a page which then passes the form data into a CFC, this might not be the best way to do it.

真正的问题是从设计的角度来看,我的逻辑非常复杂和低效。在这一刻,我唯一能想到的是通过数组传递设备值。但不知道如果我可以在一个复选框做到这一点。

Really the big problem I'm having is from a design standpoint, my logic is very convoluted and inefficient. At the moment the only thing I could think of is passing the device values in through an array. But not sure if I could do this in a checkbox.

感谢您的时间。

推荐答案

由于设备可能分配给不同的用户,因此您需要一个命名约定,您可以将每个deviceID与其相关字段(即userID,注释等)关联。一个选项是将deviceID作为后缀添加到每组字段中:

Since the devices may be assigned to different users, you need a naming convention that will allow you to associate each deviceID with its related fields ie userID, comments, etcetera. One option is to add the "deviceID" as a suffix to each set of fields:

  <cfoutput query="yourQuery">
      Device ID <input type="checkbox" name="deviceID" value="#deviceID#">
      UserID:<input type="text" name="userID_#deviceID#" ...>
      Comment:<input type="text" name="comment_#deviceID#" ...>
  </cfoutput>

说出您的查询包含三个设备ID,即 35,48,52 生成的字段名称将如下所示。注意每个设置的字段共享相同的设备ID。

Say your query contained three device id's ie 35,48,52 the resulting field names would look like this. Notice each set of fields shares the same device id.

 <input type="checkbox" name="deviceID" value="35">
 <input type="text" name="userID_35" ...>
 <input type="text" name="comment_35" ...>

 <input type="checkbox" name="deviceID" value="48">
 <input type="text" name="userID_48" ...>
 <input type="text" name="comment_48" ...>

 <input type="checkbox" name="deviceID" value="52">
 <input type="text" name="userID_52" ...>
 <input type="text" name="comment_52" ...>

然后当表单提交时, form.deviceID 将包含检查的设备的逗号分隔列表。您可以循环访问该列表,并使用当前ID来获取关联的userID和注释值。一旦你有这些值,使用 action 类型运行一个INSERT,UPDATE或任何你需要做的。

Then when the form is submitted, form.deviceID will contain a comma delimited list of the checked devices. You can loop through that list and use the current ID to grab the associated userID and comment values. Once you have those values, use the action type to run an INSERT, UPDATE or whatever you need to do.

请注意,由于每个设备可能都分配给不同的用户,因此您无法在单个语句中执行INSERT。 $ b

  <cfparam value="form.deviceID" default="">

  <!--- for each device id .. --->
  <cfloop list="#form.deviceID#" index="currDeviceID">

      <!--- grab the associated user and comment --->
      <cfset userID = FORM["userID_"& currDeviceID]>
      <cfset comment = FORM["comment_"& currDeviceID]>

      ... validate ...

      <cfquery ...>
           run your query
      </cfquery>

  </cfloop>

这篇关于设计建议:多用户多设备提交网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆